I’m trying to create a log in with facebook with Expo SDK 38 using the code for the login from the docs:
import * as Facebook from "expo-facebook";
export async function signInWithFacebook() {
try {
await Facebook.initializeAsync("688582288586140");
const {
type,
token,
expires,
permissions,
declinedPermissions,
} = await Facebook.logInWithReadPermissionsAsync({
permissions: ["public_profile"],
});
if (type === "success") {
// Get the user's name using Facebook's Graph API
const response = await fetch(
`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}`);
}
}
and i get the following error:
The method or property Facebook.initializeAsync is not available on web, are you sure you've linked all the native dependencies properly?
this is my package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "^38.0.0",
"expo-facebook": "~8.2.1",
"expo-splash-screen": "~0.3.1",
"expo-status-bar": "^1.0.0",
"firebase": "7.9.0",
"react": "16.11.0",
"react-dom": "16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"babel-preset-expo": "^8.2.3"
},
"private": true
}
I have tried re-installing all the dependencies, and i have also tried other versions of expo-facebook with no luck, what am i doing wrong?
2
Answers
i’m facing the same problem, but when i try to run this code at the redux reducer, if i run it at the component it works, have you tried Adding the values
"facebookScheme": "", "facebookAppId": "", "facebookDisplayName": "",
At the App.json, you can get those values at https://developers.facebook.com/docs/facebook-login/ios
At the step number 4
Facebook Auth for Expo web is not quite ready yet. You may keep track of the progress made here: https://github.com/expo/expo/pull/6862
All we can do is wait for the pros to handle this feature for us. We can also contribute to open source of-course.