This project comes set up with react-native-fbsdk out of the box, allowing you to take full advantage of Facebook's native SDK. Example authentication code can be found in src/providers/Facebook.tsx.
As with all third party authentication providers you will need to configure your project details to use Facebook's SDK.
Before you begin you will need to create a developer account at Facebook Developer Portal if you haven't done so already. Once you have your developer account set up:
-
Go to Facebook Developer Dashboard and create a new app id.
-
Click on Facebook Login to start the setup.
-
Select iOS quickstart in Facebook Developer Dashboard
-
Adding
FBSDKLoginKit
CocoaPod is not required as auth kit already includes it. -
Add your bundle ID when prompted and click continue.
-
If you want to allow users to sign in via notifications enable single sign on.
-
You will be given code snippets to add to your Info.plist file. To add them:
- Open your .xcworkspace project via XCode.
- Locate your
Info.plist
file and right click:Open As
->Source Code
. - Paste in your url type details snippet.
- Any other Info.plist config snippets have already been pre-configured.
- NOTE: You don't need to add
-ObjC
flag to your project as all React Native apps already include it.
-
The "Connect AppDelegate" step is not required as auth kit already includes it.
-
Select Android quickstart Facebook Developer Dashboard.
-
You don't need to download SDK, everything is already pre-configured
-
Fill in your app details.
-
Generate development key hash (as instructed in Facebook Developer Dashboard).
-
Add the generated resources to your project, you only need to update android/app/res/values/strings.xml everything else is already included. You can perform global search for
<!-- [android] facebook_app_id -->
and<!-- [android] fb_login_protocol_scheme -->
comments to find exact places where these details should be placed. -
The rest of the native implementation is already pre-configured.
Once iOS & Android have been configured, open the Facebook Developer Dashboard and Firebase Console.
-
In Firebase Console go to
Authentication
>Sign In Method
and enable Facebook. You will be prompted to enter your App ID and App Secret: -
Go to your Facebook Developer Dashboard and select your app, then go to
Settings
>Basic
. Here You will find your App ID and App secret. Copy these and add them in your Firebase Console: -
In the Firebase Console, copy the
oAuth redirect url
and go back to Facebook Developer Dashboard, here chooseFacebook Login
>Settings
and pasteoAuth redirect url
in Valid oAuth Redirect URL's field: