I have an application that still uses the legacy Facebook class to connect to Facebook. If I allow without additional permissions, everything works fine. But if I really turn on permissions, the first round for authorization always fails (although it gets a valid token!). Am I missing a step?
Here is the code to activate Facebook authorization for the application
- (IBAction) doConnect:(id)sender { NSArray* permissions = [NSArray arrayWithObjects: @"email",@"publish_actions",nil]; [self.facebook authorize:permissions]; }
Here, the code that is called after the user has granted permissions and control is returned to my application. The URL always contains a pretty marker, even the first time.
// handle the incoming url from app switching - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [self.facebook handleOpenURL:url]; }
And here is the FBSessionDelegate method, which is called after a successful connection. Despite the token contained in the above URL, it left the first time we got here. But if I call the doConnect method above, the token will be present when we come here.
}
Looking deeply into the sdk code in FBSession.m, it seems that the requested permissions were not associated with the new token for the first time, causing the session to ignore the new token. First time, cachedPermissions is always an empty list.
source share