简体   繁体   English

在 iOS 版 Facebook SDK 中登录不同的用户

[英]Login different user in Facebook SDK for iOS

I am using Facebook SDK for iOS Version 4.14 in my app.我在我的应用程序中使用 Facebook SDK for iOS 版本 4.14。 We are using facebook SDK to allow users to register.我们正在使用 facebook SDK 来允许用户注册。

We have a member of the marketing team, Say M, who will be having app installed on his phone to register new users.我们有营销团队的一名成员 Say M,他将在他的手机上安装应用程序来注册新用户。

Say if user A uses his fb details to signup the app,and he has been successfully added in the system.假设用户A使用他的fb详细信息注册了该应用程序,并且他已成功添加到系统中。

After user A is done with his registration , he logouts from the app.用户 A 完成注册后,他从应用程序注销。

Now this the problem I am facing, when M visits another user B, and if he taps on login with facebook fb session still says, that User A has already granted permission to the app.现在这是我面临的问题,当 M 访问另一个用户 B 时,如果他点击使用 facebook fb 会话登录仍然说,用户 A 已经授予该应用程序的权限。

What I want is that fb must flush all fb tokens,sessions so that M can register many new users.我想要的是 fb 必须刷新所有 fb 令牌,会话,以便 M 可以注册许多新用户。

I am handling these cases in my app我正在我的应用程序中处理这些情况

var fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()

    @IBAction func BtnLogout(sender: AnyObject) {
            FBSDKAccessToken.setCurrentAccessToken(nil)
            FBSDKProfile.setCurrentProfile(nil)
            FBSession.activeSession().closeAndClearTokenInformation()
            fbLoginManager.logOut()
            let loginManager = FBSDKLoginManager()
            loginManager.logOut()
let deleteAllpermission = FBSDKGraphRequest(graphPath: "me/permissions/", parameters: nil, HTTPMethod: "DELETE")
        deleteAllpermission.startWithCompletionHandler({(connection,result,error)-> Void in            
            print("Success")
           // in here call your login action method, it called every time user login permission

        })

        }

Just add this line of code: 只需添加以下代码行:

loginManager.loginBehavior = .web

and with every login you can auth with new credentials 并且每次登录都可以使用新凭据进行身份验证

Here we can do two things: 1. Basic one when ever we log out from app. 在这里,我们可以做两件事:1。当我们从应用程序注销时基本的。 Open browser/safari and logout from facebook also. 打开浏览器/ safari并从facebook注销。 2. second thing we can do is on log out from app we can clear the permission: ------------------------------------code---------------------------------------- 2.我们可以做的第二件事是从应用程序注销我们可以清除权限:------------------------------- - - -码 - - - - - - - - - - - - - - - - - - - -

let mypermission = FBSDKGraphRequest(graphPath: "me/permissions/", parameters: nil, HTTPMethod: "DELETE")
    mypermission.startWithCompletionHandler({(connection,result,error)-> Void in            
        print("Success")
       // in here call your login action method, it called every time user login permission

    })

(Nj) (新泽西州)

Unfortunately, there's currently no way to switch accounts within the login dialog once a user has logged in, facebook doesn't have multi-user support for Facebook Login, may be in the future they will add.不幸的是,目前无法在用户登录后在登录对话框中切换帐户,Facebook 没有对 Facebook 登录的多用户支持,他们可能会在未来添加。

Reference: https://github.com/facebook/facebook-ios-sdk/issues/1147参考: https : //github.com/facebook/facebook-ios-sdk/issues/1147

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

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