How to logout from facebook with LoginManager provided by react-native-fbsdk?

Ville Miekk-oja picture Ville Miekk-oja · Oct 14, 2017 · Viewed 10.8k times · Source

In simple, how does one log out with LoginManager provided by react-native-fbsdk?

If we look the code inside that LoginManager provided by react-native-fbsdk, we find this part regarding logout:

  logOut() {
    LoginManager.logOut();
  },

So no callback, or promise? How do I really use this then? If I call LoginManager.logout(), it actually does perform the logout. But since I'm not allowed to pass any callback, and since it doesn't return a promise, then how do I know when the logout is done, or that was it successfull? I tried providing a callback, but it resulted in error. I also tried to return a promise from it, but it also returned an error. So I don't know how is this supposed to be used? It can't be synchronous logout, right?

Answer

bennygenel picture bennygenel · Oct 14, 2017

I think its not a synchronous function but also I think you don't need to wait for it to finish. You can just use it as synchronous. I'm thinking this because if you check the default LoginButton on react-native-fbsdk onLogoutFinished prop doesn't pass any parameters about the logout action (successful, failed etc.). This means you can assume that its gonna happen without any problem since facebook itself assumed that. Default LoginButton listens for events to run onLogoutFinished function. You can try to implement something like that if you really need to.