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.
The SDK supports the existing React Native plugin for Marketing Cloud Engagement. For the most seamless experience, migrate to the React Native unified plugin.
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:
| Component | Minimum Requirement | Recommendation |
|---|---|---|
| React Native | 0.60 or later | For React Native 0.85.1 or later with the new architecture, use the React Native unified plugin. |
| iOS | See SDK for iOS release notes | Match the deployment target supported by the version of the SDK that you use. |
| Android | See SDK for Android release notes | Match the minSdk or compileSdk supported by the version of the SDK that you use. |
-
Import the SDK modules into your application.
- For iOS apps, import both
SFMCSDKandMarketingCloudSDKintoAppDelegate. - For Android apps, import
SFMCSdkintoMainApplication.java.
- For iOS apps, import both
-
Add the React Native plugin to your application using npm or Yarn.
Use this command to install the plugin by using
npm:Alternatively, use this command to install the plugin by using
yarn: