Adobe Experience Platform support for React Native apps.
npm install @adobe/react-native-aepcore

@adobe/react-native-aepcore is a wrapper around the iOS and Android Adobe Experience Platform Mobile Core Extension to allow for integration with React Native applications.
See Requirements and Installation instructions on the main page
Install the @adobe/react-native-aepcore package:
NPM:
``bash`
npm install @adobe/react-native-aepcore
Yarn:
`bash`
yarn add @adobe/react-native-aepcore
To initialize the SDK, use the following methods:
- MobileCore.initializeWithAppId(appId)
- MobileCore.initialize(initOptions)
Refer to the root Readme for more information about the SDK setup.
typescript
import { MobileCore, Lifecycle, Signal, LogLevel, PrivacyStatus, Event } from '@adobe/react-native-aepcore'
`API reference
$3
- #### collectPii
The
collectPii function lets the SDK to collect sensitive or personally identifiable information (PII).Syntax
`typescript
collectPii(data: Record)
`Example
`typescript
MobileCore.collectPii({"myPii": "data"});
`- #### initializeWithAppId
Initialize the AEP SDK by automatically registering all extensions bundled with the application and enabling automatic lifecycle tracking.
appId: Configures the SDK with the provided mobile property environment ID configured from the Data Collection UI.
To initialize the SDK, call
initializeWithAppId in your main component, typically App.tsx (or any custom entry file). Make sure it’s invoked only once using:
- componentDidMount for class-based components.
- useEffect(() => {}, []) for functional components. Although the SDK ignores repeated initialization calls, it’s best practice to avoid multiple invocations.
Syntax
`typescript
initializeWithAppId(appId: string): Promise
`Example
`typescript
useEffect(() => {
MobileCore.setLogLevel(LogLevel.DEBUG);
MobileCore.initializeWithAppId("YOUR-APP-ID")
.then(() => {
console.log("AEP SDK Initialized");
})
.catch((error) => {
console.log("AEP SDK Initialization error", error);
});
}, []);`> [!NOTE]
> Starting from Adobe Experience Platform React native 7.x, there is no longer a need to initialize the SDK on the native platforms, as was required in earlier versions.
- #### initialize
Initialize the AEP SDK by automatically registering all extensions bundled with the application and enabling automatic lifecycle tracking. This API also allows further customization by accepting InitOptions.
InitOptions: Allow customization of the default initialization behavior. Refer to the InitOptions.
To initialize the SDK, call
initialize in your main component, typically App.tsx (or any custom entry file). Make sure it’s invoked only once using:
- componentDidMount for class-based components.
- useEffect(() => {}, []) for functional components. Syntax
`typescript
initialize(initOptions?: InitOptions): Promise
`Example
`typescript// Define the initialization options
const initOptions = {
appId: "YOUR-APP-ID", // optional
lifecycleAutomaticTrackingEnabled: true, // optional
lifecycleAdditionalContextData: { contextDataKey: "contextDataValue" }, // optional
};
// Initialize the SDK
useEffect(() => {
MobileCore.setLogLevel(LogLevel.DEBUG);
MobileCore.initialize(initOptions)
.then(() => {
console.log("AdobeExperienceSDK: AEP SDK Initialized");
})
.catch((error) => {
console.error("AdobeExperienceSDK: AEP SDK Initialization error:", error);
});
}, []);
`- #### InitOptions
The InitOptions class defines the options for initializing the AEP SDK. It currently supports the following options:
* appID – The App ID used to retrieve remote configurations from Adobe servers.
* lifecycleAutomaticTrackingEnabled – A boolean flag to enable or disable automatic lifecycle tracking
* lifecycleAdditionalContextData – A map containing extra context data to be sent with the lifecycle start event.
* appGroup (iOS only) – A string representing the App Group identifier for sharing data between app extensions and the main application.
- #### dispatchEvent
Dispatch an event for other extensions or the internal SDK to consume.
Syntax
`typescript
dispatchEvent(event: Event): Promise
`Example
`typescript
import {Event} from '@adobe/react-native-aepcore';var event = new Event("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
MobileCore.dispatchEvent(event);
`- #### dispatchEventWithResponseCallback
Syntax
`typescript
dispatchEventWithResponseCallback: (event: Event, timeoutMS:Number) => Promise;
`Example
`typescript
import {Event} from '@adobe/react-native-aepcore';var event = new Event("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
MobileCore.dispatchEventWithResponseCallback(event, 1500).then(responseEvent => console.log("AdobeExperienceSDK: responseEvent = " + responseEvent));
`- #### extensionVersion
Returns the version of the Core extension
Syntax
`typescript
extensionVersion(): Promise
`Example
`typescript
MobileCore.extensionVersion().then(version => console.log("AdobeExperienceSDK: MobileCore version: " + version));
`
- #### getLogLevelThis function gets the current log level being used in the SDK.
Syntax
`typescript
getLogLevel(): Promise
`Example
`typescript
MobileCore.getLogLevel().then(level => console.log("AdobeExperienceSDK: Log Level = " + level));
`- #### getSdkIdentities
This function gets all of the user's identities known by the SDK.
Syntax
`typescript
getSdkIdentities(): Promise
`Example
`typescript
MobileCore.getSdkIdentities().then(identities => console.log("AdobeExperienceSDK: Identities = " + identities));
`- #### getPrivacyStatus
Get the current Adobe Mobile Privacy Status
Syntax
`typescript
getPrivacyStatus(): Promise
`Example
`typescript
MobileCore.getPrivacyStatus().then(status => console.log("AdobeExperienceSDK: Privacy Status = " + status));
`- #### resetIdentities
The
resetIdentities method requests that each extension resets the identities it owns and each extension responds to this request uniquely.Syntax
`typescript
resetIdentities()
`Example
`typescript
MobileCore.resetIdentities();
`- #### setPrivacyStatus
Set the Adobe Mobile Privacy status
Syntax
`typescript
setPrivacyStatus(privacyStatus: string)
`Example
`typescript
import {PrivacyStatus} from '@adobe/react-native-aepcore';MobileCore.setPrivacyStatus(PrivacyStatus.OPT_IN);
`Note:
PrivacyStatus contains the following getters:`typescript
const OPT_IN = "OPT_IN";
const OPT_OUT = "OPT_OUT";
const UNKNOWN = "UNKNOWN";
`- #### setLogLevel
Set the logging level of the SDK
Syntax
`typescript
setLogLevel(mode: LogLevel)
`Example
`typescript
import {LogLevel} from '@adobe/react-native-aepcore';MobileCore.setLogLevel(LogLevel.VERBOSE);
`- #### trackAction
> [!IMPORTANT]
> trackAction is supported through Edge Bridge and Edge Network extensions.
Track event actions that occur in your application.
Syntax
`typescript
trackAction(action?: string, contextData?: Record)
`Example
`typescript
MobileCore.trackAction("loginClicked", {"customKey": "value"});
`- #### trackState
> [!IMPORTANT]
> trackState is supported through Edge Bridge and Edge Network extensions.
Track states that represent screens or views in your application.
Syntax
`typescript
trackState(state?: string, contextData?: Record)
`Example
`typescript
MobileCore.trackState("homePage", {"customKey": "value"});
`- #### updateConfiguration
Update the configuration programmatically by passing configuration keys and values to override the existing configuration.
Syntax
`typescript
updateConfiguration(configMap?: Record)
`Example
`typescript
MobileCore.updateConfiguration({"yourConfigKey": "yourConfigValue"});
`- #### clearUpdatedConfiguration
You can clear any programmatic updates made to the configuration via the
clearUpdatedConfiguration API.Syntax
`typescript
clearUpdatedConfiguration()
`Example
`typescript
MobileCore.clearUpdatedConfiguration();
`$3
- #### appendVisitorInfoForURL
This function appends Adobe visitor information to the query component of the specified URL.
Syntax
`typescript
appendVisitorInfoForURL(baseURL?: String): Promise
`Example
`typescript
Identity.appendVisitorInfoForURL("test.com").then(urlWithVisitorData => console.log("AdobeExperienceSDK: VisitorData = " + urlWithVisitorData));
`- #### extensionVersion
Returns the version of the Identity extension
Syntax
`typescript
extensionVersion(): Promise
`Example
`typescript
Identity.extensionVersion().then(version => console.log("AdobeExperienceSDK: Identity version: " + version));
`- #### getUrlVariables
This function returns an appropriately formed string that contains the Experience Cloud Identity Service URL variables.
Syntax
`typescript
getUrlVariables(): Promise
`Example
`typescript
Identity.getUrlVariables().then(urlVariables => console.log("AdobeExperienceSDK: UrlVariables = " + urlVariables));
`- #### getIdentifiers
This function returns all customer identifiers that were previously synced with the Adobe Experience Cloud Identity Service.
Syntax
`typescript
getIdentifiers(): Promise>
`Example
`typescript
Identity.getIdentifiers().then(identifiers => console.log("AdobeExperienceSDK: Identifiers = " + identifiers));
`- #### getExperienceCloudId
This function retrieves the Adobe Experience Cloud ID (ECID) that was generated when the app was initially launched and is stored in the Adobe Experience Cloud Identity Service.
Syntax
`typescript
getExperienceCloudId(): Promise
`Example
`typescript
Identity.getExperienceCloudId().then(cloudId => console.log("AdobeExperienceSDK: CloudID = " + cloudId));
`- #### syncIdentifier
The
syncIdentifier, syncIdentifiers and syncIdentifiersWithAuthState functions update the specified customer IDs with the Adobe Experience Cloud Identity Service.Syntax
`typescript
syncIdentifier(identifierType: String, identifier: String, authenticationState: MobileVisitorAuthenticationState)
`Example
`typescript
Identity.syncIdentifier("identifierType", "identifier", MobileVisitorAuthenticationState.AUTHENTICATED);
`- #### syncIdentifiers
Syntax
`typescript
syncIdentifiers(identifiers?: Record)
`Example
`typescript
Identity.syncIdentifiers({"id1": "identifier1"});
`- #### syncIdentifiersWithAuthState
Syntax
`typescript
syncIdentifiersWithAuthState(identifiers: Record | null, authenticationState: MobileVisitorAuthenticationState)
`Example
`typescript
import {MobileVisitorAuthenticationState} from '@adobe/react-native-aepcore';Identity.syncIdentifiersWithAuthState({"id1": "identifier1"}, MobileVisitorAuthenticationState.UNKNOWN);
`Note:
MobileVisitorAuthenticationState contains the following getters:`typescript
const AUTHENTICATED = "VISITOR_AUTH_STATE_AUTHENTICATED";
const LOGGED_OUT = "VISITOR_AUTH_STATE_LOGGED_OUT";
const UNKNOWN = "VISITOR_AUTH_STATE_UNKNOWN";
`- #### setAdvertisingIdentifier
Submits a generic event containing the provided IDFA with event type
generic.identity.Syntax
`typescript
setAdvertisingIdentifier(advertisingIdentifier?: string)
`Example
`typescript
MobileCore.setAdvertisingIdentifier("adID");
`- #### setPushIdentifier
Submits a generic event containing the provided push token with event type
generic.identity.Syntax
`typescript
setPushIdentifier(pushIdentifier?: string)
`Example
`typescript
MobileCore.setPushIdentifier("pushIdentifier");
`- #### VisitorID Class:
`typescript
import {VisitorID} from '@adobe/react-native-aepcore';var visitorId = new VisitorID(idOrigin?: string, idType: string, id?: string, authenticationState?: MobileVisitorAuthenticationState)
`$3
> Note: Implementing Lifecycle via Javascript may lead to inaccurate Lifecycle metrics, therefore we recommend implementing Lifecycle in native Android and iOS code.
> To enable Lifecycle metrics for the Edge workflows, see (Lifecycle for Edge Network) (https://developer.adobe.com/client-sdks/documentation/lifecycle-for-edge-network).
- #### extensionVersion
Returns the version of the Lifecycle extension
Syntax
`typescript
extensionVersion(): Promise
`Example
`typescript
Lifecycle.extensionVersion().then(version => console.log("AdobeExperienceSDK: Lifecycle version: " + version));
`$3
- #### extensionVersion
Returns the version of the Signal extension
Syntax
`typescript
extensionVersion(): Promise
`Example
`typescript
Signal.extensionVersion().then(version => console.log("AdobeExperienceSDK: Signal version: " + version));
``