简体   繁体   English

使用FBLoginView自定义注销

[英]Customize Logout using FBLoginView

I'm putting together an iOS app and I'm using the FBLoginView as explained here. 我正在组装一个iOS应用程序,并且正在使用FBLoginView,如此处所述。 http://www.appcoda.com/ios-programming-facebook-login-sdk/ 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). 登录时,我选择了一个标签栏控制器,并且有一个“更多”标签,在该标签上我想显示更多的选项和一个“注销”选项(与Facebook iOS应用程序完全一样)。

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? 我的问题是-我可以挂钩Logout菜单选项来触发由FBLoginViewDelegate处理的Logout并选择返回登录视图,还是必须使用FBSession类手动实现登录和注销?

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: 您应该使用自己的UI进行登录和注销,忘记FBLoginView并创建自己的登录按钮的操作,并将代码放在下面:

     [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. 要注销,您只需清除fb会话并访问令牌。

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

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