Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-native-fbsdk-next

> 编程语言
Open source

React Native FBSDK Next This project aims to keep continuity of the React Native FBSDK from Facebook. As Facebook dropped support from it. …

794 stars0 likes0 views
WebsiteGitHub

About

React Native FBSDK Next This project aims to keep continuity of the React Native FBSDK from Facebook. As Facebook dropped support from it. …

React Native FBSDK Next

This project aims to keep continuity of the React Native FBSDK from Facebook. As Facebook dropped support from it. As a community for this is our effort in order to keep upgrading and improving support for this module.

React Native FBSDK is a wrapper around the iOS Facebook SDK and Android Facebook SDK, allowing for Facebook integration in React Native apps. Access to native components, from login to sharing, is provided entirely through documented JavaScript modules so you don't have to call a single native function directly.

Functionality is provided through one single npm package so you can use it for both platforms without downloading any extra packages. Follow this guide to use react-native-fbsdk in your React Native app. You can also visit https://developers.facebook.com/docs/react-native for tutorials and reference documentation.

  • Installation
  • Usage
  • Contributing
  • License

Installation

React Native Compatibility

To use this library you need to ensure you match up with the correct version of React Native you are using.

FB SDK lib version Required React Native Version
>= 9.3.0+ react-native-fbsdk-next > 4.3.0 >=0.63.3*
>= 9.0.0+ react-native-fbsdk-next >= 3.0.1 >= 0.60
= 1.0.0` >= 0.60
⚠️ * Attention

Please notice that this module in versions after 4.2.0 only supports React Native versions above 0.63.3 as it's the oldest version of React Native which support latest XCode version. Technically, it may work on older versions (test it to be sure) but they are not supported. Changes that accidentally break older react-native versions may be issued without regard to semantic versioning constraints because we do not test against the older versions. Please see this issue for an example of a previous break. Please update to current react-native versions.

1. Install the library

using either Yarn:

bash
yarn add react-native-fbsdk-next

or npm:

bash
npm install --save react-native-fbsdk-next

2. Link

  • React Native 0.60+

CLI autolink feature links the module while building the app.

Note For iOS using cocoapods, run:

bash
$ cd ios/ && pod install
  • **React Native For support with React Native Manually link the library on iOS

Either follow the instructions in the React Native documentation to manually link the framework or link using Cocoapods by adding this to your Podfile:

ruby
pod 'react-native-fbsdk-next', :path => '../node_modules/react-native-fbsdk-next'

Manually link the library on Android

Make the following changes:

android/settings.gradle

groovy
include ':react-native-fbsdk-next'
project(':react-native-fbsdk-next').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk-next/android')

android/app/build.gradle

groovy
dependencies {
   ...
   implementation project(':react-native-fbsdk-next')
}

android/app/src/main/.../MainApplication.java

On top, where imports are:

java
import com.facebook.reactnative.androidsdk.FBSDKPackage;

Add the FBSDKPackage class to your list of exported packages.

java
@Override
protected List getPackages() {
    return Arrays.asList(
            new MainReactPackage(),
            new FBSDKPackage()
    );
}

3. Configure projects

3.1 Android

Before you can run the project, follow the Getting Started Guide for Facebook Android SDK to set up a Facebook app. You can skip the build.gradle changes since that's taken care of by the rnpm link step above, but make sure you follow the rest of the steps such as updating strings.xml and AndroidManifest.xml. In addition, keep in mind that you have to point the Key Hash generation command at your app's debug.keystore file. You can find its location by checking storeFile in one of the build.gradle files (its default path is android/app/build.gradle however this can vary from project to project).

3.2 iOS

Follow steps 2, 3 and 4 in the Getting Started Guide for Facebook SDK for iOS.

Setup Instructions by React Native Version

React Native

#import

2. Inside `didFinishLaunchingWithOptions`, add the following:
   ```objc
      [[FBSDKApplicationDelegate sharedInstance] application:application
                          didFinishLaunchingWithOptions:launchOptions];
   ```
3. After this step, if you run into this `build` issue: `Undefined symbols for architecture x86_64:`, 
then you need to create a new file `File.swift` on your project folder. After doing this, you will get a prompt from `Xcode` asking if you would like to create a `Bridging Header`. Click accept.
4. From the facebook-ios-sdk docs steps 1-3, but in Objective-C since they have moved to Swift for their examples - make something like the following code is in AppDelegate.m:
   ```objc
   - (BOOL)application:(UIApplication *)app
               openURL:(NSURL *)url
               options:(NSDictionary *)options
   {
     return [[FBSDKApplicationDelegate sharedInstance]application:app
                                                         openURL:url
                                                         options:options];
   }
   

…

objc
#import  //  //  //  //  *)options
{
  if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
    return YES;
  }

  if ([RCTLinkingManager application:app openURL:url options:options]) {
    return YES;
  }

  return NO;
}

…

swift
import FBSDKCoreKit              //  Bool {
  
  // ... your existing code ...
  
  // Initialize Facebook SDK
  ApplicationDelegate.shared.application(
    application,
    didFinishLaunchingWithOptions: launchOptions
  )
  
  // Request App Tracking Transparency authorization (iOS 14+)
  if #available(iOS 14, *) {
    ATTrackingManager.requestTrackingAuthorization { _ in
      AppEvents.shared.activateApp()
    }
  } else {
    AppEvents.shared.activateApp()
  }
  
  // ... rest of your code ...
  
  return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
3. Add openURL Method for Facebook SSO

CRITICAL: This method is required for Facebook login to work when the Facebook app is installed on the device.

swift
public override func application(
  _ app: UIApplication,
  open url: URL,
  options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
  // Facebook SDK must be checked FIRST
  let handledByFB = ApplicationDelegate.shared.application(
    app, open: url, options: options)
  
  // Then call super
  let handledBySuper = super.application(
    app, open: url, options: options)
  
  return handledByFB || handledBySuper
}

If you're using React Native's RCTLinkingManager for Deep Links:

swift
public override func application(
  _ app: UIApplication,
  open url: URL,
  options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
  // IMPORTANT: Facebook SDK must be checked FIRST
  let handledByFB = ApplicationDelegate.shared.application(
    app, open: url, options: options)
  
  // Then React Native Linking
  let handledByRN = RCTLinkingManager.application(
    app, open: url, options: options)
  
  // Finally super
  let handledBySuper = super.application(
    app, open: url, options: options)
  
  return handledByFB || handledByRN || handledBySuper
}

NOTE: The order is critical: FBSDKApplicationDelegate must be checked before RCTLinkingManager. If RCTLinkingManager is placed first, it will intercept the Facebook SSO callback URL and treat it as a regular deep link, breaking Facebook Single Sign-On functionality.

4. (Optional) Activate App When It Becomes Active
swift
open override func applicationDidBecomeActive(_ application: UIApplication) {
  super.applicationDidBecomeActive(application)
  AppEvents.shared.activateApp()
}

Expo Bare Workflow Setup

If you're using Expo in Bare Workflow, your AppDelegate.swift will extend ExpoAppDelegate instead of the standard React Native app delegate. The setup is similar but with some Expo-specific considerations:

Required Imports
swift
import Expo
import React
import FBSDKCoreKit              //  Bool {
    
    // Your existing Expo setup code...
    
    // Initialize Facebook SDK
    ApplicationDelegate.shared.application(
      application,
      didFinishLaunchingWithOptions: launchOptions
    )
    
    // Request tracking authorization
    if #available(iOS 14, *) {
      ATTrackingManager.requestTrackingAuthorization { _ in
        AppEvents.shared.activateApp()
      }
    } else {
      AppEvents.shared.activateApp()
    }
    
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
  
  // CRITICAL: Required for Facebook SSO to work
  public override func application(
    _ app: UIApplication,
    open url: URL,
    options: [UIApplication.OpenURLOptionsKey: Any] = [:]
  ) -> Bool {
    let handledByFB = ApplicationDelegate.shared.application(
      app, open: url, options: options)
    let handledByRN = RCTLinkingManager.application(
      app, open: url, options: options)
    let handledBySuper = super.application(
      app, open: url, options: options)
    
    return handledByFB || handledByRN || handledBySuper
  }
  
  // Optional: Activate app when it becomes active
  open override func applicationDidBecomeActive(_ application: UIApplication) {
    super.applicationDidBecomeActive(application)
    AppEvents.shared.activateApp()
  }
}

…


    Undefined symbols for architecture x86_64:
        "_swift_FORCE_LOAD$_swiftUniformTypeIdentifiers", referenced from:
        _swift_FORCE_LOAD$swiftUniformTypeIdentifiers$_FBSDKShareKit in libFBSDKShareKit.a(Enums+Extensions.o)
        (maybe you meant: _swift_FORCE_LOAD$swiftUniformTypeIdentifiers$_FBSDKShareKit)
        "_swift_FORCE_LOAD$_swiftCoreMIDI", referenced from:
        _swift_FORCE_LOAD$swiftCoreMIDI$_FBSDKShareKit in libFBSDKShareKit.a(Enums+Extensions.o)
        (maybe you meant: _swift_FORCE_LOAD$swiftCoreMIDI$_FBSDKShareKit)
        "_swift_FORCE_LOAD$_swiftWebKit", referenced from:
        _swift_FORCE_LOAD$swiftWebKit$_FBSDKCoreKit in libFBSDKCoreKit.a(AccessToken.o)
        _swift_FORCE_LOAD$swiftWebKit$_FBSDKCoreKit in libFBSDKCoreKit.a(Permission.o)
        _swift_FORCE_LOAD$swiftWebKit$_FBSDKCoreKit in libFBSDKCoreKit.a(Settings.o)
        _swift_FORCE_LOAD$swiftWebKit$_FBSDKLoginKit in libFBSDKLoginKit.a(FBLoginButton.o)
        _swift_FORCE_LOAD$swiftWebKit$_FBSDKLoginKit in libFBSDKLoginKit.a(LoginManager.o)
        _swift_FORCE_LOAD$swiftWebKit$_FBSDKShareKit in libFBSDKShareKit.a(Enums+Extensions.o)
        (maybe you meant: _swift_FORCE_LOAD$swiftWebKit$_FBSDKLoginKit, _swift_FORCE_LOAD$swiftWebKit$_FBSDKShareKit , _swift_FORCE_LOAD$swiftWebKit$_FBSDKCoreKit )
        ld: symbol(s) not found for architecture x86_64
    ```

   After **[facebook-ios-sdk](https://github.com/facebook/facebook-ios-sdk) v7** (written with Swift parts) you need to coordinate Swift language usage with Objective-

Issues· 28 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言