@adobe/react-native-aepcore
v6.0.2
Published
Adobe Experience Platform support for React Native apps.
Downloads
46,352
Readme
React Native Adobe Experience Platform Mobile Core Extension
@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.
Installation
See Requirements and Installation instructions on the main page
Install the @adobe/react-native-aepcore
package:
npm install @adobe/react-native-aepcore
Usage
Initializing and registering the extension
Initializing the SDK should be done in native code, documentation on how to initialize the SDK can be found here.
Importing the Mobile Core package:
In your React Native application, import the core/lifecycle/signal/identity extension as follows:
import { MobileCore, Lifecycle, Signal, LogLevel, PrivacyStatus, Event } from '@adobe/react-native-aepcore'
API reference
Core
collectPii
The collectPii
function lets the SDK to collect sensitive or personally identifiable information (PII).
Syntax
collectPii(data: Record<string, string>)
Example
MobileCore.collectPii({"myPii": "data"});
dispatchEvent
Dispatch an event for other extensions or the internal SDK to consume.
Syntax
dispatchEvent(event: Event): Promise<boolean>
Example
import {Event} from '@adobe/react-native-aepcore';
var event = new Event("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
MobileCore.dispatchEvent(event);
dispatchEventWithResponseCallback
Syntax
dispatchEventWithResponseCallback: (event: Event, timeoutMS:Number) => Promise<Event>;
Example
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
extensionVersion(): Promise<string>
Example
MobileCore.extensionVersion().then(version => console.log("AdobeExperienceSDK: MobileCore version: " + version));
getLogLevel
This function gets the current log level being used in the SDK.
Syntax
getLogLevel(): Promise<LogLevel>
Example
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
getSdkIdentities(): Promise<string>
Example
MobileCore.getSdkIdentities().then(identities => console.log("AdobeExperienceSDK: Identities = " + identities));
getPrivacyStatus
Get the current Adobe Mobile Privacy Status
Syntax
getPrivacyStatus(): Promise<string>
Example
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
resetIdentities()
Example
MobileCore.resetIdentities();
setPrivacyStatus
Set the Adobe Mobile Privacy status
Syntax
setPrivacyStatus(privacyStatus: string)
Example
import {PrivacyStatus} from '@adobe/react-native-aepcore';
MobileCore.setPrivacyStatus(PrivacyStatus.OPT_IN);
Note: PrivacyStatus
contains the following getters:
const OPT_IN = "OPT_IN";
const OPT_OUT = "OPT_OUT";
const UNKNOWN = "UNKNOWN";
setLogLevel
Set the logging level of the SDK
Syntax
setLogLevel(mode: LogLevel)
Example
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
trackAction(action?: string, contextData?: Record<string, string>)
Example
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
trackState(state?: string, contextData?: Record<string, string>)
Example
MobileCore.trackState("homePage", {"customKey": "value"});
updateConfiguration
Update the configuration programmatically by passing configuration keys and values to override the existing configuration.
Syntax
updateConfiguration(configMap?: Record<string, any>)
Example
MobileCore.updateConfiguration({"yourConfigKey": "yourConfigValue"});
clearUpdatedConfiguration
You can clear any programmatic updates made to the configuration via the clearUpdatedConfiguration
API.
Syntax
clearUpdatedConfiguration()
Example
MobileCore.clearUpdatedConfiguration();
Identity
appendVisitorInfoForURL
This function appends Adobe visitor information to the query component of the specified URL.
Syntax
appendVisitorInfoForURL(baseURL?: String): Promise<string>
Example
Identity.appendVisitorInfoForURL("test.com").then(urlWithVisitorData => console.log("AdobeExperienceSDK: VisitorData = " + urlWithVisitorData));
extensionVersion
Returns the version of the Identity extension
Syntax
extensionVersion(): Promise<string>
Example
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
getUrlVariables(): Promise<string>
Example
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
getIdentifiers(): Promise<Array<VisitorID>>
Example
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
getExperienceCloudId(): Promise<string>
Example
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
syncIdentifier(identifierType: String, identifier: String, authenticationState: MobileVisitorAuthenticationState)
Example
Identity.syncIdentifier("identifierType", "identifier", MobileVisitorAuthenticationState.AUTHENTICATED);
syncIdentifiers
Syntax
syncIdentifiers(identifiers?: Record<string, string>)
Example
Identity.syncIdentifiers({"id1": "identifier1"});
syncIdentifiersWithAuthState
Syntax
syncIdentifiersWithAuthState(identifiers: Record<string, string> | null, authenticationState: MobileVisitorAuthenticationState)
Example
import {MobileVisitorAuthenticationState} from '@adobe/react-native-aepcore';
Identity.syncIdentifiersWithAuthState({"id1": "identifier1"}, MobileVisitorAuthenticationState.UNKNOWN);
Note: MobileVisitorAuthenticationState
contains the following getters:
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
setAdvertisingIdentifier(advertisingIdentifier?: string)
Example
MobileCore.setAdvertisingIdentifier("adID");
setPushIdentifier
Submits a generic event containing the provided push token with event type generic.identity
.
Syntax
setPushIdentifier(pushIdentifier?: string)
Example
MobileCore.setPushIdentifier("pushIdentifier");
VisitorID Class:
import {VisitorID} from '@adobe/react-native-aepcore';
var visitorId = new VisitorID(idOrigin?: string, idType: string, id?: string, authenticationState?: MobileVisitorAuthenticationState)
Lifecycle
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
extensionVersion(): Promise<string>
Example
Lifecycle.extensionVersion().then(version => console.log("AdobeExperienceSDK: Lifecycle version: " + version));
Signal
extensionVersion
Returns the version of the Signal extension
Syntax
extensionVersion(): Promise<string>
Example
Signal.extensionVersion().then(version => console.log("AdobeExperienceSDK: Signal version: " + version));