React Native Plugin

Use the React Native plugin to integrate the Salesforce Engagement SDK into your iOS and Android apps.

If you’re integrating the React Native plugin for the first time, use the React Native Unified Plugin.

If your package.json contains the unscoped react-native-marketingcloudsdk dependency, your app uses the Engagement-specific React Native plugin. If you’re already on the Engagement-specific React Native plugin, use this section to update your configuration or troubleshoot issues.

Important

The SDK supports the existing React Native plugin for Marketing Cloud Engagement. For the most seamless experience, migrate to the React Native unified plugin.

Note

Prerequisites 

Before you install the React Native plugin in your app, upgrade the native MarketingCloudSdk to the latest supported version. If you use MarketingCloudSdk version 7, first upgrade to version 8, and then upgrade to version 9 or later. This sequence upgrade through version 8 preserve in-place migrations, such as schema and preference upgrades. You can upgrade to a specific plugin version by using npm or Yarn.

The Engagement-specific React Native plugin has these baseline requirements:

ComponentMinimum RequirementRecommendation
React Native0.60 or laterFor React Native 0.85.1 or later with the new architecture, use the React Native unified plugin.
iOSSee SDK for iOS release notesMatch the deployment target supported by the version of the SDK that you use.
AndroidSee SDK for Android release notesMatch the minSdk or compileSdk supported by the version of the SDK that you use.

Installation 

  1. Import the SDK modules into your application.

    • For iOS apps, import both SFMCSDK and MarketingCloudSDK into AppDelegate.
    • For Android apps, import SFMCSdk into MainApplication.java.
  2. Add the React Native plugin to your application using npm or Yarn.

    Use this command to install the plugin by using npm:

    1npm install react-native-marketingcloudsdk --save

    Alternatively, use this command to install the plugin by using yarn:

    1yarn add react-native-marketingcloudsdk