8

I try to find a way to use Facebook login with Create-react-native-app for both Android and IOS. Is that possible? All this seem pretty new...

mb3
  • 101
  • 3

3 Answers3

10

Use the Expo SDK. This way you won't have to eject from create-react-native-app.

import { Facebook } from 'expo';

async function logIn() {
  const { type, token } = await Facebook.logInWithReadPermissionsAsync('<APP_ID>', {
    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}!`,
    );
  }
}

Snippet taken from the link.

fxlemire
  • 874
  • 9
  • 21
  • I have to say, I'm clueless as to why people downvoted your question... It is very legitimate. They either misread it or have no clue what create-react-native-app is. – fxlemire Aug 24 '17 at 22:36
  • Haha Thanks for your support :) I place my bet on the second ;) – mb3 Aug 28 '17 at 00:39
0

I think you can try using other library like react-native-fbsdk or react-native-facebook-login. You can read the documentation because there is an example how to implement login with facebook.

-1

User https://github.com/facebook/react-native-fbsdk library.

Tyler wrote a detailed blog on how to install the Facebook SDK into a React Native Android or iOS App. https://tylermcginnis.com/installing-the-facebook-sdk-into-a-react-native-android-and-ios-app/

You can go through them and implement Facebook login into React Native app.