简体   繁体   English

从Facebook App登录返回iOS的零令牌响应

[英]Login from Facebook App returns nil Token response for iOS

I set Login Behaviour FBSDKLoginBehaviorSystemAccount and try to login, then my app fetch details from Settings of Facebook then its give me successfully response in this class FBSDKLoginManagerLoginResult object which include token string and user id . 我设置了登录行为FBSDKLoginBehaviorSystemAccount并尝试登录,然后我的应用程序从Facebook的设置中获取了详细信息,然后在类FBSDKLoginManagerLoginResult对象中成功给了我响应,其中包括令牌字符串和用户ID。 But if there is no account added in setting of Facebook then this move user to Facebook App and after authentication when move back to app but this return nil token and no other details. 但是,如果没有在Facebook的设置中添加任何帐户,则此用户将用户移动到Facebook App,并在身份验证后又返回到app,但这将返回nil令牌和其他详细信息。 I don't know why this is happening I added some code in following. 我不知道为什么会这样,我在下面添加了一些代码。 I hope every one understand my problem those who performed login from Facebook in iOS Development and someone still no then kindly tell me will add more details. 我希望每个人都了解我的问题,那些在iOS开发中从Facebook执行登录的人,然后仍然不愿意告诉我的人会添加更多详细信息。

if (![self isCurrentAccessTokenValid] ) {
        self.FBLoginManager.loginBehavior = FBSDKLoginBehaviorSystemAccount;
        [self.FBLoginManager logInWithReadPermissions:@[ @"email",@"public_profile",@"user_friends"] handler:
         ^(FBSDKLoginManagerLoginResult *result, NSError *error) {
             block(result, error);
             NSLog(@"%@",result.token.tokenString);
             NSLog(@"%@",result.token.userID);
             //NSLog(@"%hhd",result.isCancelled);

             [FBSDKAccessToken setCurrentAccessToken:result.token];

        }];
    } else {
        [self fetchUserProfile:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
            block(result, error);
        }];
    }

Looking for helpful response. 寻找有用的回应。 Thanks. 谢谢。

Try this 尝试这个

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    [login
     logInWithReadPermissions: @[@"public_profile", @"email", @"user_friends"]
     handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
         if (error) {
             NSLog(@"Process error");
         } else if (result.isCancelled) {
             NSLog(@"Cancelled");
         } else {
             NSLog(@"Logged in");             
         }
     }];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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