2

When I try to login to Facebook in expo android app, getting the following error

null is not an object (evaluating 'LoginManager.logInWithPermissions')

const SignInwithFB = async () => {
    try { 
      await LoginManager.logInWithPermissions(["public_profile", "email"]);
      const data = await AccessToken.getCurrentAccessToken();
      if (!data) {
        return;
      }
      const facebookCredential = FacebookAuthProvider.credential(data.accessToken);
      const auth = getAuth(firebase);
      const response = await signInwithCredential(auth, facebookCredential);
      console.log(response);
    } catch (e) {
      console.log(e);
    }
  }
installed by following this instructions: https://www.npmjs.com/package/react-native-fbsdk-next
Satyam rai
  • 21
  • 1

1 Answers1

0

Check Expo installation section in npm install page, make sure you have implemented the instruction

const SignInwithFB = async () => {
        try { 
         const loginManagerResult =  await LoginManager.logInWithPermissions(["public_profile", "email"]);
         if(loginManagerResult) {
          const data = await AccessToken.getCurrentAccessToken();
          if (!data) {
            return;
          }
          const facebookCredential = FacebookAuthProvider.credential(data.accessToken);
          const auth = getAuth(firebase);
          const response = await signInwithCredential(auth, facebookCredential);
          console.log(response);
         }
        } catch (e) {
          console.log(e);
        }
      }