Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

A wrapper around the iOS and Android AEP mobile SDK to allow for integration with React Native applications.

License

Notifications You must be signed in to change notification settings

Alterra-Mountain-Company/aepsdk-react-native

 
 

Repository files navigation

aepsdk-react-native

license CircleCI

About this project

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.

Package Name Latest Version Native Extension
@adobe/react-native-aepcore (required) npm version npm downloads Mobile Core
@adobe/react-native-aepuserprofile npm version npm downloads Profile
@adobe/react-native-aepedge npm version npm downloads Edge
@adobe/react-native-aepedgeidentity npm version npm downloads EdgeIdentity
@adobe/react-native-aepedgeconsent npm version npm downloads EdgeConsent
@adobe/react-native-aepmessaging npm version npm downloads Messaging
@adobe/react-native-aepassurance npm version npm downloads Assurance
@adobe/react-native-aepoptimize npm version npm downloads Optimize
@adobe/react-native-aepplaces npm version npm downloads Places
@adobe/react-native-aeptarget npm version npm downloads Target
@adobe/react-native-aepcampaignclassic npm version npm downloads CampaignClassic

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.

Requirements

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.

Installation

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.

Install AEP npm packages

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
ios development

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

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.

iOS
//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.

Android:
//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

Migration guide

See migration.md for guidance on migrating from ACP React Native libraries.

Contributing

Contributions are welcomed! See CONTRIBUTING and development.md guides for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

About

A wrapper around the iOS and Android AEP mobile SDK to allow for integration with React Native applications.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 41.1%
  • Java 35.5%
  • Objective-C 18.7%
  • Ruby 1.7%
  • C++ 1.3%
  • Objective-C++ 0.9%
  • Other 0.8%