React Native Adobe Experience Platform Edge Network extension
@adobe/react-native-aepedge
is a wrapper around the iOS and Android Adobe Experience Platform Edge Network to allow for integration with React Native applications.
Prerequisites
The Edge Network extension has the following peer dependencies, which must be installed prior to installing the Edge extension:
Installation
See Requirements and Installation instructions on the main page
Install the @adobe/react-native-aepedge
package:
cd MyReactApp
npm install @adobe/react-native-aepedge
Usage
Installing and registering the extension with the AEP Mobile Core
Install the Adobe Experience Platform Edge Network extension in your mobile property and configure the default Datastream ID by following the steps in the Edge Network extension documentation.
Then follow the same document for registering the Edge extension with the Mobile Core. Note that initializing the SDK should be done in native code, additional documentation on how to initialize the SDK can be found here.
Initialization Example
iOS
// AppDelegate.h
@import AEPCore;
@import AEPEdge;
@import AEPEdgeIdentity;
...
@implementation AppDelegate
// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AEPMobileCore setLogLevel: AEPLogLevelDebug];
[AEPMobileCore registerExtensions:@[AEPMobileEdgeIdentity.class,
AEPMobileEdge.class] completion:^{
[AEPMobileCore configureWithAppId:@"yourAppID"];
...
}];
return YES;
}
@end
Android
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Edge;
...
import android.app.Application;
...
public class MainApplication extends Application implements ReactApplication {
...
@Override
public void on Create(){
super.onCreate();
...
MobileCore.setApplication(this);
MobileCore.setLogLevel(LoggingMode.DEBUG);
MobileCore.configureWithAppID("yourAppID");
Edge.registerExtension();
com.adobe.marketing.mobile.edge.identity.Identity.registerExtension();
MobileCore.start(new AdobeCallback() {
@Override
public void call(Object o) {
}});
}
}
Importing the extension
In your React Native application, import the Edge extension as follows:
import {Edge, ExperienceEvent} from '@adobe/react-native-aepedge';
API reference
extensionVersion
Syntax
extensionVersion(): Promise<string>;
Example
Edge.extensionVersion().then(version => console.log("AdobeExperienceSDK: Edge version: " + version));
sendEvent
Syntax
sendEvent(experienceEvent: ExperienceEvent): Promise<Array<EdgeEventHandle>>;
Example
var xdmData = {"eventType" : "SampleXDMEvent"};
var data = {"free": "form", "data": "example"};
let experienceEvent = new ExperienceEvent(xdmData, data);
// send ExperienceEvent ignoring the promise
Edge.sendEvent(experienceEvent);
// send ExperienceEvent with promise
Edge.sendEvent(experienceEvent).then(eventHandles => console.log("Edge.sentEvent returned EdgeEventHandles = " + JSON.stringify(eventHandles)));
Public classes
ExperienceEvent
Create Experience Event from Dictionary:
var xdmData = {"eventType" : "SampleXDMEvent"};
let experienceEvent = new ExperienceEvent(xdmData);
Add free form data to the Experience event:
var xdmData = {"eventType" : "SampleXDMEvent"};
var data = {"free": "form", "data": "example"};
let experienceEvent = new ExperienceEvent(xdmData, data);
Set the destination Dataset identifier to the current Experience event:
var xdmData = {"eventType" : "SampleXDMEvent"};
let experienceEvent = new ExperienceEvent(xdmData, null, "datasetIdExample")
Create Experience Event with xdmdata, free form data and the destination Dataset identifier:
var xdmData = {"eventType" : "SampleXDMEvent"};
var data = {"dataKey" : "dataValue"};
let experienceEvent = new ExperienceEvent(xdmData, data, "datasetIdExample")