How to remove all application data on react native?

5.9k views Asked by At

How to remove all application data on react native?

Not only AsyncStorage.clear(). I mean deleting application data like through settings > application. I have faced EUNSPECIFIED error code with react-native-fbsdk.

First I logged in with my facebook account, Second I logged out from it, Third I relogin with this account (It works well) And then I logged out again, And I tried to log in with another facebook account, But I faced EUNSPECIFIED error.

But after deleting all app data (not uninstall) through settings > application, I can login with another facebook account.

I have to delete all applilcation data when logged out from my react native application. OR I have to fix this react-native-fbsdk's bug (or I guess fbsdk is caching some data....)

Already I put AsyncStorage.clear() when logout, No changes..

Appreciate for your help...

1

There are 1 answers

4
Gui Herzog On BEST ANSWER

I had this problem with FBSDK as well and the problem is that when you login with facebook, the SDK creates an AccessToken linked to the old user. Therefore, when you try to login with another account, it throws this weird error message.

What you have to do is to logout the user on the fbAPI. The code below is how you do it:

// Remove FbAccessToken when the user logout.
logoutFromFB(){
    if (AccessToken.getCurrentAccessToken() != null) {
        LoginManager.logOut()
    }
}

I hope it helps!