문제

Facing the following problem: need to perform Facebook login in IOS 7. The thing goes right on the emulator but when running it on device with native app installed, the session give not permission to perform the login.

Using the code to create session: enter image description here

The checarLogin method works like:

enter image description here

I have googled to find it and figured out that the device settings that control the permissions of Facebook app works differently in the two cases:

Emulator give the permission with no issues:

enter image description here

The following image was took from emulator too, but only to illustrate the way the device works by default:

enter image description here

So the question is: there is other way to handle the login when running in a real device with native Facebook app installed and make it accept the permissions without the need to change the iphone settings?

도움이 되었습니까?

해결책

This is what I use in my apps, you have to allow the login UI.

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI completionHandler:(FBSessionStateHandler)handler {

// We pass this permissions array into our request.
// I only request email, but there are many more options.
//
NSArray *permissions = @[@"email", @"basic_info"];

return [FBSession
        openActiveSessionWithReadPermissions:permissions
        allowLoginUI:allowLoginUI
        completionHandler:^(FBSession *session,
                            FBSessionState state,
                            NSError *error) {

            if (handler)
                handler(session, state, error);
        }];

}

And that's how you use it

        [self openSessionWithAllowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {

            if (!error && status == FBSessionStateOpen) {
                NSString *token = session.accessTokenData.accessToken;

                // You're logged in!

            } else {

                // Something wrong happened

            }
        }];

다른 팁

I faced a similar problem, and this is what worked for me:

https://stackoverflow.com/a/12069251/2407717

A colleague changed some of our project settings, including the Bundle Identifier, so it wasn't matching the iOS Bundle ID on Facebook anymore.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top