Provides Facebook integration for Expo apps. Expo exposes a minimal native API since you can access Facebook's Graph API directly through HTTP (using fetch, for example).
Add host.exp.Exponent as an iOS Bundle ID. Add rRW++LUjmZZ+58EbN5DVhGAnkX4= as an Android key hash. Your app's settings should end up including the following under "Settings > Basic":
iOS standalone app
Add your app's Bundle ID as a Bundle ID in app's settings page pictured above.
In your app.json, add a field facebookScheme with your Facebook login redirect URL scheme found here under 4. Configure Your info.plist. It should look like "fb123456".
permissions (array) -- An array specifying the permissions to ask for from Facebook for this login. The permissions are strings as specified in the Facebook API documentation. The default permissions are ['public_profile', 'email'].
Returns
If the user or Facebook cancelled the login, returns { type: 'cancel' }.
Otherwise, returns { type: 'success', token, expires, permissions, declinedPermissions }. token is a string giving the access token to use with Facebook HTTP API requests. expires is the time at which this token will expire, as seconds since epoch. You can save the access token using, say, AsyncStorage, and use it till the expiration time. permissions is a list of all the approved permissions, whereas declinedPermissions is a list of the permissions that the user has rejected.
Example
asyncfunctionlogIn(){try{const{
type,
token,
expires,
permissions,
declinedPermissions,}=await Facebook.logInWithReadPermissionsAsync('<APP_ID>',{
permissions:['public_profile'],});if(type ==='success'){// Get the user's name using Facebook's Graph APIconst response =awaitfetch(`https://graph.facebook.com/me?access_token=${token}`);
Alert.alert('Logged in!',`Hi ${(await response.json()).name}!`);}else{// type === 'cancel'}}catch({ message }){alert(`Facebook Login Error: ${message}`);}}
Given a valid Facebook application ID in place of <APP_ID>, the code above will prompt the user to log into Facebook then display the user's name. This uses React Native's fetch to query Facebook's Graph API.