0
votes

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.

2
use this link this will use for u stackoverflow.com/questions/23170846/…Anbu.Karthik
you need to open it in web view ?Basheer_CAD
I am not using webView. I need it to be opened with the native ios facebook app installed in the device. if not then use safari etc.SaffronState

2 Answers

0
votes

Issue just resolved by deleting the test app and it's associated test users that i created in the "developer.facebook.com->app" page under "Test Apps". This is weird but resolved all my problems.

Though my above code works fine but I found "Build Your Own Button" part in https://developers.facebook.com/docs/facebook-login/ios/v2.0#login-apicalls is useful and I modified my code according to this link.

In this same link I also noticed which I was not aware of:

"When someone connects with an app using Facebook login, the app can access their public profile and friend list, the pieces of information that are visible to everyone. To create this basic connection, apps must always request access to a person's public profile information by asking for the public_profile permission."

Hope this will help someone else!!!

0
votes

I had this same issue recently. I was able to fix it by upgrading from version 4.6.0 of FBSDKCoreKit to version 4.7.0.

Facebook strongly recommends using the FBSDK libs over the old Facebook-iOS-SDK, so switching is a good idea.

Also, make sure you set the proper LSApplicationQueriesSchemes if you're on iOS 9

Facebook has some info on iOS 9 integration here: https://developers.facebook.com/docs/ios/ios9