Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fbDidLogin not called

So, I've been messing around with the Facebook iOS SDK for a bit and as of the latest version I can't get the fbDidLogin method to be called. The login process works fine, with Safari used on the simulator and the Facebook app being used when running it on a device. However, after logging in I get transferred back to my app (as I should be) but as the fbDidLogin method hasn't been called, nothing has changed. As far as my app is concerned I'm not logged in. The demo app that is bundled with the SDK works fine. So I'm obviously doing something wrong, but I have no idea how to check what. I triple-checked all the methods used in the demo app against my own and as far as I can see everything looks the same. Any thoughts or ideas on how to debug this? Or has anyone had similar problems?

Thanks!

like image 529
Glitch Avatar asked Nov 22 '10 10:11

Glitch


3 Answers

I encountered the same issue just now. I solved it by adding the following code into my application delegate:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [[controller facebook] handleOpenURL:url];
}

where controller is my UIViewController instance and facebook is my Facebook instance.

You also need to register your app to handle your fb application's URL scheme (do that in you Info.plist).

like image 154
Jiri Avatar answered Nov 19 '22 06:11

Jiri


One common mistake could be to not implement the following callback method in your main app delegate, but elsewhere. Implement this method in your class derived from UIApplicationDelegate. This is the entry point that iOS calls after the context switch to bring your application back to foreground.

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
     // obtain facebook instance ref
     [ facebook handleOpenURL: url ];
   }

If you have created FB application Id correctly and mapped the URL appropriately as defined in https://developers.facebook.com/docs/guides/mobile/#ios then it should work.

like image 27
savvybud Avatar answered Nov 19 '22 06:11

savvybud


I solved the problem, If facebook is the object of your first viewcontroller that is being loaded by ur appdelegate, then you can use viewcontroller property of appdelegate to refer facebook object e.g

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
     [ viewController.facebook handleOpenURL: url ];
}
like image 2
Ali Sufian Avatar answered Nov 19 '22 06:11

Ali Sufian