简体   繁体   中英

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. I basically copied everything from the demoApp but I have a problem when I try to login to facebook.

I press the login button and then the facebook app opens. I authorize myself and press OK. Then I am redirected to my app, but then the fbDidLogin() method gets not called. I also defined my app ID in my view controller and the url schema in the info file.

Am I missing something?

Thanks, Cheers, Doonot

fbDidLogin() isn't an Objective C method. Is that the way you have it in the code?

Have you handled your custom URL scheme in your app delegate?

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:

...
- (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. Thanks to the settingsViewController I simply added:

// 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.

Cheers, Doonot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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