Skip to content

Instantly share code, notes, and snippets.

@brunokiafuka
Created September 17, 2019 09:59
Show Gist options
  • Save brunokiafuka/8f6171397a64e5421300bd07d65034dc to your computer and use it in GitHub Desktop.
Save brunokiafuka/8f6171397a64e5421300bd07d65034dc to your computer and use it in GitHub Desktop.
export const facebookLogin = async () => {
try {
const { type, token } = await Facebook.logInWithReadPermissionsAsync('<YOUR APP ID>', {
permissions: ['public_profile', 'email', 'user_birthday'],
behavior: 'native',
});
if (type === 'success') {
// Get the user's name using Facebook's Graph API
const credential = firebase.auth.FacebookAuthProvider.credential(token)
firebase.auth().signInWithCredential(credential).catch((error) => {
console.log(error)
})
const uid = firebase.auth().currentUser.uid; //this would return you the user id
//then you can perform other stuff like, saving their names to an object ect...
return await response.json();
}
// type === 'cancel'
return 'cancel';
} catch ({ message }) {
return console.error(`Facebook Login Error: ${message}`);
}
};
@SHMapps
Copy link

SHMapps commented Sep 17, 2019

thanks bro, it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment