Skip to content
This repository has been archived by the owner. It is now read-only.

Latest commit

 

History

History
139 lines (119 loc) · 5.12 KB

setup-facebook.md

File metadata and controls

139 lines (119 loc) · 5.12 KB

Set up authentication using Facebook Sign-In

Android

  1. Add the following project variable to your variables.gradle file (usually android/build.gradle):

    ext {
    +    rgcfaIncludeFacebook = true
    }

    Run npx cap update to update the native plugins and dependencies.

  2. See Before you begin and follow the instructions to configure sign-in with Facebook correctly.
    Attention: Skip step 4. The dependency for the Firebase Authentication Android library is already declared by the plugin.

  3. Add the following string elements to android/app/src/main/res/values/strings.xml after the resources element:

    <string name="facebook_app_id">[APP_ID]</string>
    <string name="fb_login_protocol_scheme">fb[APP_ID]</string>

    [APP_ID] must be replaced with your Facebook app ID.

  4. Add the following elements to android/app/src/main/AndroidManifest.xml inside the application element:

    <meta-data
       android:name="com.facebook.sdk.ApplicationId"
       android:value="@string/facebook_app_id"/>
    
    <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>

iOS

  1. Add the RobingenzCapacitorFirebaseAuthentication/Facebook pod to your Podfile (usually ios/App/Podfile):

    target 'App' do
    capacitor_pods
    # Add your Pods here
    +  pod 'RobingenzCapacitorFirebaseAuthentication/Facebook', :path => '../../node_modules/@robingenz/capacitor-firebase-authentication'
    end

    Run npx cap update to update the native plugins and dependencies.

  2. See Before you begin and follow the instructions to configure and enable sign-in with Facebook correctly.
    Attention: Skip step 2. The Firebase/Auth pod is already added by the plugin.

  3. Add the following import in your app's AppDelegate.swift:

    import FBSDKCoreKit
  4. 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
    }
  5. 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)
    +   }
    }
  6. 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.

Web

  1. See Before you begin and follow the instructions to configure and enable sign-in with Facebook correctly.