简体   繁体   中英

IOS FACEBOOK SDK, LOGOUT FROM FB AND LOGIN AFTER

I have read lots of different question on this on SO but never find what I am looking for. I am trying to find out if the following behaviour is normal or not.

This is for IOS.

Let's assume my app is called TEST for the rest of the topic.

Here is what I would like to do:

1) I go in the TEST app and login with facebook (for the first time ever).

2) Facebook will open and ask me to approve I want to login. I approve.

3) TEST App has now a facebook token.

4) In TEST app I click a button to logout which deletes my facebook token.

5) I login again in the TEST app.

6) Because I already have approved in 2) that I accept to login with TEST app. I would expect to land directly in 3) but as of now I always land on 2).

I think this is maybe the default behaviour, but then I do not get how other apps like tinder are able to let you logout and login without showing that step 2).

So my questions are:

1) Are the steps above default behaviour?

2) If not, what am I missing.

For reference this is my code:

    if([FBSDKAccessToken currentAccessToken] != nil)
        [self loginUser];
    else{
        FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
        login.loginBehavior = FBSDKLoginBehaviorSystemAccount;

        // THIS PART ALWAYS SWAP FROM MY APP TO FACEBOOK APP
        [login logInWithReadPermissions:@[FACEBOOK_EMAIL, FACEBOOK_PUBLICPROFILE] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
                if (error){
                    [login logOut];
                }
                else if ([result isCancelled] == YES){
                    [login logOut];
                }
                else{
                    [self loginUser];
                }
            }];

    }

EDIT:

AS suggested by shikha kochar, I have updated my PLIST but still not working, attached few additional screenshots

PLIST: 在此输入图像描述

APP DELEGATE EXTRACT: 在此输入图像描述

There is nothing Wrong in Your code,, check your Result !! make sure add fbauth2 in infoplist 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM