React native fbsdk user change issue on both IOS and Android
Asked Answered
K

3

7

I use this (https://github.com/facebook/react-native-fbsdk) component in attempts to setup authentication to my app using Facebook. I've successfully configured it so login button gives me a valid token on both platforms.

Problem is that application records successfully logged user and it is pretty tricky to get rid of it (only reinstall can help). Moreover, when you try to change logged a user in facebook application on android - it gives an error:

'User logged in as different Facebook user'

I always receive this screen instead of a login form, where I can enter other credentials or at least change the account.

I use provided LoginManager.logInWithReadPermissions for login and LoginManager.logOut seems to do nothing.

So, is it possible for me to make application to give a user a choice if the login was not correct or main-fb-app account has changed?

Kristelkristen answered 23/10, 2017 at 13:0 Comment(3)
same issue here, any progress on that?Plantar
Problem solved particularly. I successfully configured Android-part so it gives no errors now and LoginManager.logOut() works good for Android. IOS still remembers logged in user so I cant change account inside my application.Kristelkristen
@StanislavMatviichuck What did you do exactly ?Bakehouse
K
4

This appears to be an unresolved issue https://github.com/facebook/react-native-fbsdk/issues/536

Do your part – Please vote up this issue so it can be resolved by the FB team in the future.

Answer – Currently, this question is not possible to resolve.

Dev Workaround – If you are in development and need to test multiple users, you can use a different emulator authenticate with another login.

If this gets resolved by FB, please consider editing this answer

Katleen answered 22/7, 2020 at 14:15 Comment(0)
P
1
FBLogout = async () => {
try{
    let tokenObj = await AccessToken.getCurrentAccessToken();
    let current_access_token = tokenObj.accessToken.toString();
    let logout = new GraphRequest(
        "me/permissions/",
        {
            accessToken: current_access_token,
            httpMethod: 'DELETE'
        },
        (error, result) => {
            if (error) {
                console.log('Error fetching data: ' + error.toString());
            } else {
                LoginManager.logOut();
            }
        });
     new GraphRequestManager().addRequest(logout).start() 
}catch(error}{
 console.log(error);
}
  }
Piscatelli answered 23/12, 2020 at 19:47 Comment(0)
C
-2

Open Safari on your simulator or device, go to www.facebook.com.

You will see that you are still logged in there with the original account. Just log out there and then you'll be able to use a different one in your react native app.

Cloe answered 12/12, 2017 at 11:21 Comment(3)
Not true for me on simulator! even though I'm logged in, safari shows that I am logged out. If I login on safari facebook with a different account, my app completely ignores that and stays logged in with the original account. I haven't tried it on my device yet.Chenault
This answer is a bit old, maybe something has changed in the latest Facebook SDKs. Maybe if the Facebook app is installed in your device, then you need to make sure you are logged out there as well.Cloe
On the device it works fine! Only on the simulator you can't change accountsChenault

© 2022 - 2024 — McMap. All rights reserved.