且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在ios app.cannot切换用户中,facebook没有正确注销

更新时间:2023-12-02 13:28:46

//logout code
- (IBAction)logoutButtonPressed:(id)sender { 

使用以下代码

 if (FBSession.activeSession.state == FBSessionStateOpen
        || FBSession.activeSession.state == FBSessionStateOpenTokenExtended) {



    // Close the session and remove the access token from the cache
    // The session state handler (in the app delegate) will be called automatically
    [FBSession.activeSession closeAndClearTokenInformation];

    // If the session state is not any of the two "open" states when the button is clicked
} else {
    // Open a session showing the user the login UI
    // You must ALWAYS ask for public_profile permissions when opening a session
    [FBSession openActiveSessionWithReadPermissions:@[@"public_profile"]
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session, FBSessionState state, NSError *error) {
             }];
}