setup-facebook-login.mo

Prerequisites (~15 min)

Context

When I had to install a facebook login on my React Native project, I thought it would be easy and that I would only have to follow the tutorial of the github repo. But, by simply following the tutorial, I found myself with many problems of versions on both iOS and Android.

I hope that thanks to this article which summarizes the tips that I could find online, you will be able to install a facebook login in less than an hour.

Steps (~20 min)

Install react-native-fbsdk package (https://github.com/facebook/react-native-fbsdkarrow-up-right): yarn add react-native-fbsdk@0.6.0 (last release 0.6.1 bug on react native link)

iOS (~10 min)

  • Link it react-native link react-native-fbsdk

  • Add in your podfile the library's dependencies:

       target 'accorlocal' do
         inherit! :search_paths
         pod 'FBSDKCoreKit', '~> 4.25.0'
         pod 'FBSDKShareKit', '~> 4.25.0'
         pod 'FBSDKLoginKit', '~> 4.25.0'
       end

    cd ios && bundle exec pod install --repo-update

  • Then follow the documentationarrow-up-right -> Fill your app id -> Configure your info.plist -> connect the App Delegate

check: console.log(NativeModules) should show the FacebookLoginManager module on iOS build

Android (~10 min)

  • Then follow the documentationarrow-up-right -> "If your react-native version is 0.29 or above"

  • Go to Facebook developerarrow-up-right -> Fill your app id -> And follow "Add Facebook App ID"

  • There are versions issues on the nodes_modules. To fix them, add a script in /bin/patch-fb-sdk.sh and add it in your package.json as a post install command:

  • To debug with android, on you terminal generate a key: keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 and add it to your facebook apparrow-up-right -> Key hashings

check 1: console.log(NativeModules) should show the FacebookLoginManager module on Android build check 2: You should be able to log on Facebook on your application on Android on development

Add the Facebook login button

Now, you should be able to add the login button on your app working on both Android and iOS. You just have to import react-native-fbsdk and add your Facebook button

You can find more configuration herearrow-up-right

Last updated