简体   繁体   English

iPhone Facebook SDK登录问题

[英]iPhone Facebook SDK Login Problem

Hey guys I just tried to implement the facebook sdk like in the DemoApp from Facebook itself into my application. 大家好,我只是尝试将DemosApp中的facebook sdk从Facebook本身实现到我的应用程序中。 I basically copied everything from the demoApp but I have a problem when I try to login to facebook. 我基本上从demoApp复制了所有内容,但是当我尝试登录Facebook时遇到问题。

I press the login button and then the facebook app opens. 我按登录按钮,然后打开Facebook应用程序。 I authorize myself and press OK. 我授权自己,然后按OK。 Then I am redirected to my app, but then the fbDidLogin() method gets not called. 然后,我被重定向到我的应用程序,但是随后未调用fbDidLogin()方法。 I also defined my app ID in my view controller and the url schema in the info file. 我还在视图控制器中定义了我的应用程序ID,在信息文件中定义了URL模式。

Am I missing something? 我想念什么吗?

Thanks, Cheers, Doonot 谢谢,干杯,杜诺

fbDidLogin() isn't an Objective C method. fbDidLogin()不是Objective C方法。 Is that the way you have it in the code? 那是您在代码中拥有它的方式吗?

Have you handled your custom URL scheme in your app delegate? 您是否在应用程序委托中处理了自定义URL方案?

Ok after some trying I figured it out. 确定,经过一番尝试,我发现了。 I used the Interface Builder to set up my Tab Bar Application. 我使用界面生成器来设置我的标签栏应用程序。 I had to change the tab bar application to programmatically in order to have a reference to the view controller which implements the facebook login method: 我必须以编程方式将选项卡栏应用程序更改为对实现Facebook登录方法的视图控制器的引用:

...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
        settingsController = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];  
 ...

As Jim mentioned, I forgot to implement the custom url scheme in my app delegate. 如Jim所述,我忘记在我的应用程序委托中实现自定义url方案。 Thanks to the settingsViewController I simply added: 多亏了settingsViewController我简单地添加了:

// this method is needed by the facebook login procedure
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [[settingsController facebook] handleOpenURL:url];
}

That's it, after these changes I can finally login to facebook. 就这样,完成这些更改后,我终于可以登录到facebook了。

Cheers, Doonot 干杯,杜诺

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM