Created
September 17, 2019 09:59
-
-
Save brunokiafuka/8f6171397a64e5421300bd07d65034dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks bro, it works