Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 510
Ville Miekk-oja Avatar asked Oct 14 '17 13:10

Ville Miekk-oja


2 Answers

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.

like image 132
bennygenel Avatar answered Nov 14 '22 04:11

bennygenel


For me, this works:

import { LoginManager } from 'react-native-fbsdk'
LoginManager.logOut()
like image 3
Orsos Patrick Avatar answered Nov 14 '22 04:11

Orsos Patrick