1

嗨,请检查此代码以集成 Facebook,但我无法使用不同的 Facebook 用户登录

[login logInWithReadPermissions: @[@"public_profile", @"email",@"user_likes",@"user_groups",@"user_managed_groups"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    if ([result.declinedPermissions containsObject:@"publish_actions"]) {
        NSLog(@"declained permissions");
    } else {
        if ([FBSDKAccessToken currentAccessToken]) {
            [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:[NSDictionary dictionaryWithObject:@"id,name,first_name,last_name,gender,email,picture.type(large),groups" forKey:@"fields"]]
             startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

                 if (error==nil) {

                     NSString *facebookToken = [FBSDKAccessToken currentAccessToken].tokenString;
                     NSLog(@"user token is = %@",facebookToken);
                 }else {

                     NSLog(@"facebook erro : %@ ",error);
                 }
             }];
        }
    }
}];
4

1 回答 1

0

为了从之前的Facebook 登录中“注销”当前用户,您必须撤销他们对应用程序的访问权限。换句话说,你DELETE之前的许可。

这将确保在注销和重新登录时将提示用户重新验证自己 重新允许应用程序的权限。


来自 Facebook 的开发者页面

撤销登录

您可以通过调用 Graph API 删除所有权限来撤销应用程序的所有权限。使用 Revoke Permissions 中的代码并将请求的路径更改为 /me/permissions。

Objective-C

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/permissions" parameters:nil
                                   HTTPMethod:@"DELETE"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // ... Do anything here upon finishing this call.
}]; 

迅速

let deletepermission = FBSDKGraphRequest(graphPath: "me/permissions/", parameters: nil, HTTPMethod: "DELETE")
    deletepermission.startWithCompletionHandler({(connection,result,error)-> Void in            
        println("the delete permission is \(result)")

    })
于 2018-03-07T16:54:12.813 回答