简体   繁体   English

与Facebook iOS SDK共享后从Facebook注销

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

I'm building an iPad app where the user can post an image to his/her timeline. 我正在构建一个iPad应用程序,用户可以在其中将图像发布到他/她的时间轴上。 These iPads are rentable, so the user should be logged out after the share has been done. 这些iPad是可出租的,因此共享完成后应注销用户。

I've implemented the iOS Facebook Login, so the user is redirected to Safari to login. 我已经实现了iOS Facebook登录,因此将用户重定向到Safari进行登录。 After the share I clean up all the tokens and within my app the session is destroyed, but when I go to Safari afterwards the user is still logged in. 共享之后,我清理了所有令牌,并在我的应用程序中破坏了该会话,但是当我随后进入Safari时,用户仍然登录。

Is there a way to make sure the user is logged out everywhere? 有没有办法确保用户到处注销?

Kind regards, Frederik 亲切的问候,弗雷德里克

I've done something similar in the past. 我过去做过类似的事情。 It was a flow where any user holding the iPad logs in with his or hers FB credentials, forcing the sdk to present a webview. 在此流程中,任何持有iPad的用户都使用其FB凭据登录,从而迫使SDK呈现Web视图。

A quick look, this is the code I wrote for it: (this code is 1.5y old) 快速浏览一下,这是我为此编写的代码:(此代码已使用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];
        }
    }];

When the flow ends, or the user cancels the flow, I logs the user out as follows: 当流程结束或用户取消流程时,我将用户注销如下:

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

UPDATE: The code for the share dialog: 更新:共享对话框的代码:

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