I'm trying to connect new users through Facebook authentication and Firebase SDK with createContext, but I'm getting: new FacebookAuthProvider()
is not supported on the native Firebase SDKs.
I'm using the firebase doc here : https://firebase.google.com/docs/auth/web/facebook-login and here : https://github.com/firebase/snippets-web/blob/1452a031ee1b7904a361b23391af8533237eab82/auth/facebook.js#L9-L9
My code :
import React, {createContext, useState} from 'react';
import auth from '@react-native-firebase/auth';
import firebase from '@react-native-firebase/app';
export const AuthContext = createContext({});
export const AuthProvider = ({children}) => {
const [user, setUser] = useState(null);
return (
<AuthContext.Provider
value={{
user,
setUser,
login: async (email, password) => {
try {
await auth().signInWithEmailAndPassword(email, password);
} catch (e) {
return handleError(e);
}
},
register: async (email, password) => {
try {
await auth().createUserWithEmailAndPassword(email, password);
} catch (e) {
return handleError(e);
}
},
logout: async () => {
try {
await auth().signOut();
} catch (e) {
return handleError(e);
}
},
loginWithFacebook: async (processRequest) => {
try {
let provider = new firebase.auth.FacebookAuthProvider();
provider.addScope('user_birthday');
provider.setCustomParameters({
display: 'popup',
});
await firebase.auth().signInWithPopup(provider);
} catch (e) {
console.log(e);
}
},
}}>
{children}
</AuthContext.Provider>
);
};
If someone have another idea for using facebook connection with firebase SDK and useContext I'm okay too.