I am stumped by the Facebook API for logging in. I can\'t find anything helpful on the net.
My FBSessionDelegate methods are not being called, and accessToken and expira
There are few examples on the net that show how this works, but the Facebook SDK is distributed with a demo app (DemoApp) that works once you plug in the appId. (If you don't plug in the appId value, it will get killed when it checks for that value.)
What is happening in the authorization process is that [facebook authorize:permissions] is called. (permissions should not be nil)
This leads to a call to [self authorize:permissions localAppId:nil], which then calls [self authorizeWithFBAppAuth:YES safariAuth:YES]. In that method, three ways of connecting to facebook for authorization can be tried.
In each of these asynchronous methods, the application delegate is the delegate that handles the resulting callback as part of the to application:(UIApplication *)application handleOpenURL:(NSURL *)url. If this was mentioned in the other online tutorials, it's easy to miss, because they generally do all of the processing within the application delegate, from what I saw. In my case, I did the main processing within the main view controller.
The fix, in my case, was to move the application:(UIApplication *)application handleOpenURL:(NSURL *)url method to the application delegate and point it to the facebook object like this:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [[controller facebook] handleOpenURL:url];
}
After that, the other facebook delegate methods (fbDidLogin, fbDidLogout) were called and I received the accessToken and expirationDate. So it looks like this is working now.