简体   繁体   中英

Login different user in Facebook SDK for iOS

I am using Facebook SDK for iOS Version 4.14 in my app. We are using facebook SDK to allow users to register.

We have a member of the marketing team, Say M, who will be having app installed on his phone to register new users.

Say if user A uses his fb details to signup the app,and he has been successfully added in the system.

After user A is done with his registration , he logouts from the app.

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.

What I want is that fb must flush all fb tokens,sessions so that M can register many new users.

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. Open browser/safari and logout from facebook also. 2. second thing we can do is on log out from app we can clear the permission: ------------------------------------code----------------------------------------

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.

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

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