简体   繁体   中英

Customize Logout using FBLoginView

I'm putting together an iOS app and I'm using the FBLoginView as explained here. http://www.appcoda.com/ios-programming-facebook-login-sdk/

I've now got a working app that displays a Login button and after logging out it becomes a Logout button. Obviously this isn't a realistic implementation of a Logout button. On login I'm segueing to a Tab Bar controller and I have a More tab on which I want to display a number of further options and a Logout option (exactly as the Facebook iOS app does).

My question is - can I hook a Logout menu option to fire the Logout that is handled by FBLoginViewDelegate and segue back to the Login view or do I have to manually implement login and logout using the FBSession class?

You should use your own UI for login and logout, Forget FBLoginView and create action of your own login button and put the code below:

     [FBSession openActiveSessionWithReadPermissions:@[@"email"]
                                          allowLoginUI:YES
                                     completionHandler:
        ^(FBSession *session, FBSessionState state, NSError *error) {

            if (error) {

                 // error

             }else {

                // user logged in
             }
         }];

    }

To logout, you just need to clear fb session and access token.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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