Set up authentication using Facebook Sign-In
January 8, 2026 · View on GitHub
Android
-
Add
facebook.comto theprovidersconfiguration array. -
Add the following project variable to your
variables.gradlefile (usuallyandroid/variables.gradle):ext { + rgcfaIncludeFacebook = true }Run
npx cap updateto update the native plugins and dependencies. -
On the Facebook for Developers site, get the App ID and an App Secret for your app.
-
Enable Facebook Login:
- In the Firebase console, open the Auth section.
- On the Sign in method tab, enable the Facebook sign-in method and specify the App ID and App Secret you got from Facebook.
- Then, make sure your OAuth redirect URI (e.g.
my-app-12345.firebaseapp.com/__/auth/handler) is listed as one of your OAuth redirect URIs in your Facebook app's settings page on the Facebook for Developers site in the Product Settings > Facebook Login config.
-
Add the following
stringelements toandroid/app/src/main/res/values/strings.xmlafter theresourceselement:<string name="facebook_app_id">[APP_ID]</string> <string name="fb_login_protocol_scheme">fb[APP_ID]</string> <string name="facebook_client_token">[CLIENT_TOKEN]</string>[APP_ID]must be replaced with your Facebook App-ID.
[CLIENT_TOKEN]must be replaced with your Facebook Client Token. -
Add the following elements to
android/app/src/main/AndroidManifest.xmlinside theapplicationelement:<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/> <activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" /> <activity android:name="com.facebook.CustomTabActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="@string/fb_login_protocol_scheme" /> </intent-filter> </activity>
⚠️ You may encounter the following error with Gradle lint:
Class referenced in the manifest, com.facebook.FacebookActivity, was not found in the project or the libraries [MissingClass]. Check out this comment in that case: issues/117#issuecomment-1208612107.
iOS
-
Add
facebook.comto theprovidersconfiguration array. -
If you are using CocoaPods for your iOS project, add the
CapacitorFirebaseAuthentication/Facebookpod to yourPodfile(usuallyios/App/Podfile):target 'App' do capacitor_pods # Add your Pods here + pod 'CapacitorFirebaseAuthentication/Facebook', :path => '../../node_modules/@capgo/capacitor-firebase-authentication' endAttention: Do not add the pod in the section
def capacitor_pods, but under the comment# Add your Pods here(example).Run
npx cap updateto update the native plugins and dependencies. -
If you are using Swift Package Manager for your iOS project, the Facebook SDK dependencies are already included by default. No additional configuration is needed for the package dependencies.
-
On the Facebook for Developers site, get the App ID and an App Secret for your app.
-
Enable Facebook Login:
- In the Firebase console, open the Auth section.
- On the Sign in method tab, enable the Facebook sign-in method and specify the App ID and App Secret you got from Facebook.
- Then, make sure your OAuth redirect URI (e.g.
my-app-12345.firebaseapp.com/__/auth/handler) is listed as one of your OAuth redirect URIs in your Facebook app's settings page on the Facebook for Developers site in the Product Settings > Facebook Login config.
-
Add the following import in your app's
AppDelegate.swift:import FBSDKCoreKit -
Update the following function in your app's
AppDelegate.swift:func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + ApplicationDelegate.shared.application( + application, + didFinishLaunchingWithOptions: launchOptions + ) return true } -
Update the following function in your app's
AppDelegate.swift:func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + if ApplicationDelegate.shared.application( + app, + open: url, + sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, + annotation: options[UIApplication.OpenURLOptionsKey.annotation] + ) { + return true + } else { return ApplicationDelegateProxy.shared.application(app, open: url, options: options) + } } -
Add the following lines to your apps's
Info.plist:<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>fb[APP_ID]</string> </array> </dict> </array> <key>FacebookAppID</key> <string>[APP_ID]</string> <key>FacebookClientToken</key> <string>[CLIENT_TOKEN]</string> <key>FacebookDisplayName</key> <string>[APP_NAME]</string> <key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fbapi20130214</string> <string>fbapi20130410</string> <string>fbapi20130702</string> <string>fbapi20131010</string> <string>fbapi20131219</string> <string>fbapi20140410</string> <string>fbapi20140116</string> <string>fbapi20150313</string> <string>fbapi20150629</string> <string>fbapi20160328</string> <string>fbauth</string> <string>fb-messenger-share-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array>[APP_ID]must be replaced with your Facebook app ID.[CLIENT_TOKEN]must be replaced with your Facebook Client Token (App Dashboard > Settings > Advanced > Client Token).
[APP_NAME]must be replaced with your Facebook app name. -
Set the
NSUserTrackingUsageDescriptionkey in your app'sInfo.plist:<key>NSUserTrackingUsageDescription</key> <string>This identifier will be used to request permission to track the user's activity.</string>
Web
- See Before you begin and follow the instructions to configure and enable sign-in with Facebook correctly.