@adobe/react-native-acpcore is a wrapper around the iOS and Android AEP Core SDK to allow for integration with React Native applications. Functionality to enable the Core extension is provided entirely through JavaScript documented below.
You need to install the SDK with npm and configure the native Android/iOS project in your react native project.
Note: If you are new to React Native we suggest you follow the React Native Getting Started page before continuing.
First create a React Native project:
react-native init MyReactAppInstall and link the @adobe/react-native-acpcore package:
cd MyReactApp
npm install @adobe/react-native-acpcore- React Native 0.60+
 
CLI autolink feature links the module while building the app.
- React Native <= 0.59
 
react-native link @adobe/react-native-acpcoreNote: if using Cocoapods, run:
cd ios/ && pod installNavigate to MainApplication.java under android/app/src/main/java/com/<project-name>/MainApplication.java and add a call to MobileCore.setApplication(this) inside of onCreate().
import com.adobe.marketing.mobile.MobileCore; // import MobileCore
@Override
public void onCreate() {
	super.onCreate();
	//...
	MobileCore.setApplication(this); // add this line
}The SDK requires standard network connection permissions in your manifest to send data, collect cellular provider, and record offline tracking calls.
To add these permissions, add the following lines to your AndroidManifest.xml file, which is located in the application project directory:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
(Only required for React Native <= 0.59)
In the Link Binary With Libraries section, click the + link and add the following frameworks and libraries:
UIKit.frameworkSystemConfiguration.frameworkWebKit.frameworkUserNotifications.frameworklibsqlite3.0.tbdlibc++.tbdlibz.tbd
After you have installed Core, you can install additional AEP React Native extensions.
| Extension | npm package | 
|---|---|
| Analytics | |
| Audience | |
| Campaign | |
| Target | |
| User Profile | 
This project contains jest unit tests which are contained in the __tests__ directory, to run the tests locally:
make run-tests-locally
Note: It is recommended to initialize the SDK via native code inside your AppDelegate and MainApplication in iOS and Android respectively. However, you can still initialize the SDK in Javascript. If you initialize the SDK via native code, it is not required to initialize the SDK in Javascript.
iOS:
// Import the SDK
#import <RCTACPCore/ACPCore.h>
#import <RCTACPCore/ACPLifecycle.h>
#import <RCTACPCore/ACPIdentity.h>
#import <RCTACPCore/ACPSignal.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  //...
  [ACPCore configureWithAppId:@"yourAppId"];
  [ACPCore setWrapperType:ACPMobileWrapperTypeReactNative];
  [ACPIdentity registerExtension];
  [ACPLifecycle registerExtension];
  [ACPSignal registerExtension];
  // Register any additional extensions
  [ACPCore start:nil];
}Android:
// Import the SDK
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Identity;
import com.adobe.marketing.mobile.Lifecycle;
import com.adobe.marketing.mobile.Signal;
import com.adobe.marketing.mobile.WrapperType;
@Override
public void onCreate() {
  //...
  MobileCore.setApplication(this);
  MobileCore.configureWithAppID("yourAppId");
  MobileCore.setWrapperType(WrapperType.REACT_NATIVE);
  try {
    Identity.registerExtension();
    Lifecycle.registerExtension();
    Signal.registerExtension();
    // Register any additional extensions
  } catch (Exception e) {
    // handle exception
  }
  MobileCore.start(null);
}Javascript:
import {ACPCore, ACPLifecycle, ACPIdentity, ACPSignal, ACPMobileLogLevel} from '@adobe/react-native-acpcore';
initSDK() {
    ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);
    ACPCore.configureWithAppId("yourAppId");
    ACPLifecycle.registerExtension();
    ACPIdentity.registerExtension();
    ACPSignal.registerExtension();
    // Register any additional extensions
    
    await ACPCore.start();
}ACPCore.updateConfiguration({"yourConfigKey": "yourConfigValue"});ACPCore.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPCore version: " + version));ACPCore.getLogLevel().then(level => console.log("AdobeExperienceSDK: Log Level = " + level));import {ACPMobileLogLevel} from '@adobe/react-native-acpcore';
ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);import {ACPMobileLogLevel} from '@adobe/react-native-acpcore';
ACPCore.log(ACPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");Note: ACPMobileLogLevel contains the following getters:
const ERROR = "ACP_LOG_LEVEL_ERROR";
const WARNING = "ACP_LOG_LEVEL_WARNING";
const DEBUG = "ACP_LOG_LEVEL_DEBUG";
const VERBOSE = "ACP_LOG_LEVEL_VERBOSE";ACPCore.getPrivacyStatus().then(status => console.log("AdobeExperienceSDK: Privacy Status = " + status));import {ACPMobilePrivacyStatus} from '@adobe/react-native-acpcore';
ACPCore.setPrivacyStatus(ACPMobilePrivacyStatus.OPT_IN);Note: ACPMobilePrivacyStatus contains the following getters:
const OPT_IN = "ACP_PRIVACY_STATUS_OPT_IN";
const OPT_OUT = "ACP_PRIVACY_STATUS_OPT_OUT";
const UNKNOWN = "ACP_PRIVACY_STATUS_UNKNOWN";ACPCore.getSdkIdentities().then(identities => console.log("AdobeExperienceSDK: Identities = " + identities));import {ACPExtensionEvent} from '@adobe/react-native-acpcore';
var event = new ACPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchEvent(event);import {ACPExtensionEvent} from '@adobe/react-native-acpcore';
var event = new ACPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchEventWithResponseCallback(event).then(responseEvent => console.log("AdobeExperienceSDK: responseEvent = " + responseEvent));import {ACPExtensionEvent} from '@adobe/react-native-acpcore';
var responseEvent = new ACPExtensionEvent("responseEvent", "eventType", "eventSource", {"testDataKey": "testDataValue"});
var requestEvent = new ACPExtensionEvent("requestEvent", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchResponseEvent(responseEvent, requestEvent);ACPIdentity.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPIdentity version: " + version));ACPIdentity.registerExtension();ACPIdentity.syncIdentifiers({"id1": "identifier1"});import {ACPMobileVisitorAuthenticationState} from '@adobe/react-native-acpcore';
ACPIdentity.syncIdentifiersWithAuthState({"id1": "identifier1"}, ACPMobileVisitorAuthenticationState.UNKNOWN);Note: ACPMobileVisitorAuthenticationState contains the following getters:
const AUTHENTICATED = "ACP_VISITOR_AUTH_STATE_AUTHENTICATED";
const LOGGED_OUT = "ACP_VISITOR_AUTH_STATE_LOGGED_OUT";
const UNKNOWN = "ACP_VISITOR_AUTH_STATE_UNKNOWN";ACPCore.setAdvertisingIdentifier("adID");ACPIdentity.appendVisitorInfoForURL("test.com").then(urlWithVisitorData => console.log("AdobeExperienceSDK: VisitorData = " + urlWithVisitorData));ACPIdentity.getUrlVariables().then(urlVariables => console.log("AdobeExperienceSDK: UrlVariables = " + urlVariables));ACPIdentity.getIdentifiers().then(identifiers => console.log("AdobeExperienceSDK: Identifiers = " + identifiers));ACPIdentity.getExperienceCloudId().then(cloudId => console.log("AdobeExperienceSDK: CloudID = " + cloudId));ACPCore.setPushIdentifier("pushIdentifier");import {ACPVisitorID} from '@adobe/react-native-acpcore';
var visitorId = new ACPVisitorID(idOrigin?: string, idType: string, id?: string, authenticationState?: ACPMobileVisitorAuthenticationState)Note: Implementing Lifecycle via Javascript may lead to inaccurate Lifecycle metrics, therefore we recommend implementing Lifecycle in native Android and iOS code. However, if implementing Lifecycle in Javascript is required you can use the
AppStateto receive notifications about when your app enters foreground/background. Based on theAppStateyou can make the corresponding calls tolifecycleStartandlifecyclePause.
ACPLifecycle.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPLifecycle version: " + version));ACPLifecycle.registerExtension();ACPCore.lifecycleStart({"lifecycleStart": "myData"});ACPCore.lifecyclePause();ACPSignal.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPSignal version: " + version));ACPSignal.registerExtension();ACPCore.collectPii({"myPii": "data"});A few different errors can result from not running react-native link @adobe/react-native-acpcore or when the autolinker in React Native 0.60.x does not properly link the SDK when building.
- 
TypeError: null is not an object (evaluating RCTACPCore...) - 
ACPCore.hnot found when importing<RCTACPCore/ACPCore.h> - 
No SDK logs or errors after implementing in Javascript
 
react-native link @adobe/react-native-acpcore
cd ios/ && pod install # only if using podsAnother possible issue is that your application is built using Expo. Unfortunately Expo does not support native modules out of the box. Please see Ejecting to ExpoKit.
If you have already installed the AEP SDK into your React Native app and wish to upgrade to newer version, complete the following steps:
npm uninstall --save @adobe/react-native-acpcoreto uninstall previous versions. Be sure to do this for all extensions you're planning to upgrade e.g.npm uninstall --save @adobe/react-native-acpanalyticsif you're upgrading the Analytics extension.npm install --save-exact @adobe/react-native-acpcoreto install the latest AEP SDK. Do this with any extensions you're upgrading at the time.- Re-link and install pods if required.
 
react-native link @adobe/react-native-acpcore
cd ios/ && pod install # only if using podsSee CONTRIBUTING
See LICENSE