Here's my code, a simple attempt to authenticate users through Facebook and add them to the Firebase system in a React Native environment. I'm aware that certain parts of the Firebase library may not be fully compatible with React Native.
const auth = firebase.auth();
const provider = firebase.auth.FacebookAuthProvider;
LoginManager.logInWithReadPermissions(['public_profile'])
.then(loginResult => {
alert("login results")
if (loginResult.isCancelled) {
alert('user canceled');
return;
}
AccessToken.getCurrentAccessToken()
.then(accessTokenData => {
const credential = firebase.auth.FacebookAuthProvider.credential(accessTokenData.accessToken);
alert("Credential: " + credential )
return auth.signInWithCredential(credential);
})
.then(credData => {
console.log(credData);
alert("CRED data:::" + credData)
alert(firebase)
})
.catch(err => {
console.log(err);
alert("ERROR:::" + err)
alert(firebase)
});
});
I suspect that Firebase might either be undefined or not fully initialized, although it appears to be. Perhaps implementing a promise can ensure its proper initialization. (Any suggestions on how to do that?)
Despite Firebase seemingly being initialized, I couldn't find any reasons in the API reference as to why .auth.FacebookAuthProvider.credential would not exist.
Any assistance would be highly appreciated!