Using FB JS sdk for user authentication in react-native

428 Views Asked by At

I am aware of native ios solution. I am wondering if it is possible to use FB JS sdk in react-native to login the users. A sample code to load FB SDK below - it will throw error in react-native because document doesn't seem to be a valid object in that implementation.

(function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) return;
         js = d.createElement(s); js.id = id;
         js.src = "//connect.facebook.net/es_LA/sdk.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));

I can also use oauth2 manual login flow but using FB JS SDK seems better because it handles other scenarios like two-factor authentication.

1

There are 1 best solutions below

0
On

I would recommend using the Facebook React Native SDK Login (you can find it here) to do user authentication, I tried it and it works for signing users in...the ReadMe says delete sub projects, I was confused and deleted too many, and it didn't work, so I had to start over again, I would recommend keep the sub projects for now until we find out exactly which sub projects to delete...