This repository is a monorepo and contains a collection of React Native modules for Adobe Experience Platform Mobile SDK as listed below. These modules can be found in the packages directory.
Note: @adobe/react-native-aepassurance <=2.0 is not compatible with @adobe/react-native-aepcore. Please use @adobe/react-native-aepassurance 3.x or above.
Requires React Native >= v0.60.0
React Native v0.60.0 and above supports CLI autolink feature which links the module while building the app.
You need to install Adobe Experience Platform Mobile SDK with npm packages 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.
Adobe Experience Platform Mobile SDK packages can be installed from npm command.
Note:
@adobe/react-native-aepcore
is required to be installed.
Install the @adobe/react-native-aep{extension}
package:
cd MyReactApp
npm install @adobe/react-native-aep{extension}
Alternatively, include the Adobe Experience Platform npm packages as dependencies in the app’s package.json.
The following code snippet shows for Mobile Core and Edge Network extensions as an example in package.json:
...
"dependencies": {
"react-native": "0.64.2",
"@adobe/react-native-aepcore": "^1.0.0", //core is required and includes aepcore, aepsignal, aeplifecycle, aepidentity libraries
"@adobe/react-native-aepedge": "^1.0.0",
"@adobe/react-native-aepedgeidentity": "^1.0.0",
"@adobe/react-native-aepedgeconsent": "^1.0.0",
...
},
Inside of the app directory, run
#if using node package manager
npm install
or
#if using yarn package manager
yarn install
For iOS development, after installing the plugins from npm, download the pod dependencies by running the following command:
cd ios && pod install && cd ..
To update native dependencies to latest available versions, run the following command:
cd ios && pod update && cd ..
Initializing the SDK should be done in native code inside your AppDelegate
(iOS) and MainApplication
(Android). The following code snippets demonstrate how to install and register the AEP Mobile Core and Edge Network extensions. Documentation on how to initialize each extension can be found in ./packages/{extension}/README.md.
//AppDelegate.h
@import AEPCore;
@import AEPServices;
@import AEPLifecycle;
@import AEPSignal;
@import AEPEdge;
@import AEPEdgeIdentity;
@import AEPEdgeConsent;
...
//AppDelegate.m
...
@implementation AppDelegate
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[AEPMobileCore setLogLevel: AEPLogLevelDebug];
[AEPMobileCore configureWithAppId:@"yourAppID"];
[AEPMobileCore registerExtensions: @[
AEPMobileLifecycle.class,
AEPMobileSignal.class,
AEPMobileEdge.class,
AEPMobileEdgeIdentity.class,
AEPMobileEdgeConsent.class,
] completion:^{
[AEPMobileCore lifecycleStart:@{@"contextDataKey": @"contextDataVal"}];
//enable this for Lifecycle. See Note for collecting Lifecycle metrics.
}
];
return YES;
}
@end
To enable the Lifecycle metrics, implement the Lifecycle APIs
Hint : While running iOS application after Adobe Experience Platform SDK installation. If you have build error that states: "ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'" This is because Adobe Experience Platform SDK now requires the app uses swift interfaces. Add a dummy .swift file to your project to embed the swift standard libs. See the SampleApp presented in this repo for example.
//MainApplication.java
import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.InvalidInitException;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Lifecycle;
import com.adobe.marketing.mobile.Signal;
import com.adobe.marketing.mobile.Edge;
import com.adobe.marketing.mobile.edge.consent.Consent;
...
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);
try {
Lifecycle.registerExtension();
Signal.registerExtension();
Edge.registerExtension();
com.adobe.marketing.mobile.edge.identity.Identity.registerExtension();
Consent.registerExtension();
MobileCore.configureWithAppID("yourAppID");
MobileCore.start(new AdobeCallback() {
@Override
public void call(Object o) {
MobileCore.lifecycleStart(null);
//enable this for Lifecycle. See Note for collecting Lifecycle metrics.
}
});
} catch (InvalidInitException e) {
...
}
}
}
To enable the Lifecycle metrics, implement the Lifecycle APIs
See migration.md for guidance on migrating from ACP React Native libraries.
Contributions are welcomed! See CONTRIBUTING and development.md guides for more information.
This project is licensed under the Apache V2 License. See LICENSE for more information.