Facebook login with expo-facebook not working

  1. SDK Version: 38
  2. Platforms(Android/iOS/web/all): all

I’m trying to login with facebook auth, using the code in the docs like so:

import firebase from "./firebase";
import * as Facebook from "expo-facebook";

export async function signInWithFacebook() {
  const appId = 688582288586140;
  const permissions = ["public_profile", "email"];

  try {
    await Facebook.initializeAsync("<APP_ID>");
    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 this error message:

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
}

what am i doing wrong?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.