Code Monkey home page Code Monkey logo

aepsdk-react-native's Introduction

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-aepedgebridge npm version npm downloads EdgeBridge
@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: Since version 5.0.0 of the Adobe React Native SDK, all React Native libraries that share the same major version are compatible with each other.

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.

  • Requires Xcode 14.1+

To submit iOS apps to the App Store, you must build them using Xcode 14.1 or later, as required by Apple.

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": "^5.0.0", //core is required and includes aepcore, aepsignal, aeplifecycle, aepidentity libraries
    "@adobe/react-native-aepedge": "^5.0.0",
    "@adobe/react-native-aepedgeidentity": "^5.0.0",
    "@adobe/react-native-aepedgeconsent": "^5.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"];

  const UIApplicationState appState = application.applicationState;

  [AEPMobileCore registerExtensions: @[
      AEPMobileLifecycle.class,
      AEPMobileSignal.class,
      AEPMobileEdge.class,
      AEPMobileEdgeIdentity.class,
      AEPMobileEdgeConsent.class,
  ] completion:^{
    if (appState != UIApplicationStateBackground) {
       [AEPMobileCore lifecycleStart:nil}];
    }
  }];
  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.Extension;
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);
    MobileCore.configureWithAppID("yourAppID");
    List<Class<? extends Extension>> extensions = Arrays.asList(
                Lifecycle.EXTENSION,
                Signal.EXTENSION,
                Edge.EXTENSION,
                com.adobe.marketing.mobile.edge.identity.Identity.EXTENSION,
                Consent.EXTENSION);
    MobileCore.registerExtensions(extensions, o -> {
      Log.d(LOG_TAG, "AEP Mobile SDK is initialized");
      MobileCore.lifecycleStart(null);
      //enable this for Lifecycle. See Note for collecting Lifecycle metrics.
    });
  }
}

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.

aepsdk-react-native's People

Contributors

ahmyr avatar cacheung avatar dsoffiantini avatar emdobrin avatar kevindice avatar praveek avatar pravinpk avatar rymorale avatar sbenedicadb avatar shtomar-adb avatar swarna04 avatar yangyansong-adbe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.