繁体   English   中英

与Facebook iOS SDK共享后从Facebook注销

[英]Logout from Facebook after a share with Facebook iOS SDK

我正在构建一个iPad应用程序,用户可以在其中将图像发布到他/她的时间轴上。 这些iPad是可出租的,因此共享完成后应注销用户。

我已经实现了iOS Facebook登录,因此将用户重定向到Safari进行登录。 共享之后,我清理了所有令牌,并在我的应用程序中破坏了该会话,但是当我随后进入Safari时,用户仍然登录。

有没有办法确保用户到处注销?

亲切的问候,弗雷德里克

我过去做过类似的事情。 在此流程中,任何持有iPad的用户都使用其FB凭据登录,从而迫使SDK呈现Web视图。

快速浏览一下,这是我为此编写的代码:(此代码已使用1.5岁)

 FBSession *newSession = [[FBSession alloc] initWithPermissions:@[
                             @"user_about_me",
                             @"publish_actions",
                             @"user_birthday",
                             @"friends_birthday",
                             @"email"
                            ]];


    [FBSession setActiveSession:newSession];

    [[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {

        [FBSession setActiveSession:session];

        if(error){
            NSLog(@"Error opening session");
            [self showLoginError:error];
            return;
        }

        if(status == FBSessionStateOpen){
            NSLog(@"FB session opened");
            [self getMe];
        }
    }];

当流程结束或用户取消流程时,我将用户注销如下:

[[FBSession activeSession] closeAndClearTokenInformation];    
[FBSession setActiveSession:nil];

更新:共享对话框的代码:

NSMutableDictionary *dialogParameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   [NSString stringWithFormat:@"%@ - Vote for us!", 
                                   teamName, @"name",
                                   @"Campaign title", @"caption",
                                   shareMessage, @"description",
                                   shareTeamPageURL, @"link",
                                   sharePictureURL, @"picture", nil];


    [FBWebDialogs presentFeedDialogModallyWithSession:[FBSession activeSession] 
    parameters:dialogParameters 
    handler:nil];

暂无
暂无

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

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