I am using xcode 5.1.1, ios 7.1.1, cocos2d 2.1, facebook ios sdk 3.14 on mac OSX Maverics 10.9.2.
I have defined a FBSession property in appDelegate. And in another CCMenuItemImage click event I have
if (appDelegate.session.isOpen) {
[appDelegate.session closeAndClearTokenInformation];
} else
{
if (appDelegate.session.state != FBSessionStateCreated) {
// Create a new, logged out session.
appDelegate.session = [[FBSession alloc] init];
}
appDelegate.session = [[[FBSession alloc] initWithPermissions:permissions] autorelease];
// if the session isn't open, let's open it now and present the login UX to the user
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
NSLog(@"IT NEVER PRINTS %@",session.accessTokenData.accessToken);
}];
}
And in appDelegate.m I have:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// attempt to extract a token from the url
return [FBAppCall handleOpenURL:url
sourceApplication:sourceApplication
withSession:self.session];
}
When i run the sample facebook code it launches the facebook ios native app to login/ask for permission. And when I run this above code it does nothing. I tried with and without signing into facebook ios app and settings->general-facebook. In developer.facebook.com app setting I have SSO enabled. Please help.
EDIT:
I am getting random issues like: 1> the error: "FBSDKLog: Cannot use the Facebook app or Safari to authorize, fb**** is not registered as a URL Scheme". 2> getting the access token without a valid FBSession. 3> Sometime the webpage login windows popped with the #1 error mentioned above. 4> And some time the above error#3 pops and goes off with log printing user canceled.