Socket
Socket
Sign inDemoInstall

@adobe/react-native-acpcore

Package Overview
Dependencies
Maintainers
41
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adobe/react-native-acpcore

Adobe Experience Platform support for React Native apps.


Version published
Weekly downloads
7.8K
increased by6.46%
Maintainers
41
Weekly downloads
 
Created
Source

React Native AEP Core Extension

npm version CircleCI NPM

@adobe/react-native-acpcore is a wrapper around the iOS and Android AEP Core SDK to allow for integration with React Native applications. Functionality to enable the Core extension is provided entirely through JavaScript documented below.

Contents

Installation

You need to install the SDK with npm 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.

1. Create React Native project

First create a React Native project:

react-native init MyReactApp

2. Install JavaScript packages

Install and link the @adobe/react-native-acpcore package:

cd MyReactApp
npm install @adobe/react-native-acpcore
react-native link @adobe/react-native-acpcore

3. Configure native projects

3.1 Android project

Navigate to MainApplication.java under android/app/src/main/java/com/<project-name>/MainApplication.java and add a call to MobileCore.setApplication(this) inside of onCreate().

import com.adobe.marketing.mobile.MobileCore; // import MobileCore

@Override
public void onCreate() {
	super.onCreate();
	//...
	MobileCore.setApplication(this); // add this line
}
3.2 iOS project

In the Link Binary With Libraries section, click the + link and add the following frameworks and libraries:

  • UIKit.framework
  • SystemConfiguration.framework
  • WebKit.framework
  • UserNotifications.framework
  • libsqlite3.0.tbd
  • libc++.tbd
  • libz.tbd

Note: If you plan to use the AEP SDK in your native iOS code you will need to import the appropriate headers with the following format: #import <RCTACPCore/ACPCore.h>

Tests

This project contains jest unit tests which are contained in the __tests__ directory, to run the tests locally:

make run-tests-locally

Usage

Core

Initializing the SDK:

It is recommended to initialize the SDK in your native code inside your AppDelegate and MainApplication in iOS and Android respectively, however you can still initialize the SDK in Javascript.

iOS:

// Import the SDK
#import <RCTACPCore/ACPCore.h>
#import <RCTACPCore/ACPLifecycle.h>
#import <RCTACPCore/ACPIdentity.h>
#import <RCTACPCore/ACPSignal.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  //...
  [ACPCore configureWithAppId:@"yourAppId"];
  [ACPCore setWrapperType:ACPMobileWrapperTypeReactNative];
  [ACPIdentity registerExtension];
  [ACPLifecycle registerExtension];
  [ACPSignal registerExtension];

  [ACPCore start:nil];
}

Android:

@Override
public void onCreate() {
  //...
  MobileCore.setApplication(this);
  MobileCore.configureWithAppID("yourAppId");
  MobileCore.setWrapperType(WrapperType.REACT_NATIVE);
  try {
    Identity.registerExtension();
    Lifecycle.registerExtension();
    Signal.registerExtension();
  } catch (Exception e) {
    // handle exception
  }

  MobileCore.start(null);
}

Javascript:

import {ACPCore, ACPLifecycle, ACPIdentity, ACPSignal, ACPMobileLogLevel} from '@adobe/react-native-acpcore';

initSDK() {
    ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);
    ACPCore.configureWithAppId("yourAppId");
    ACPLifecycle.registerExtension();
    ACPIdentity.registerExtension();
    ACPSignal.registerExtension();
    ACPCore.start();
}
Updating the SDK configuration:
ACPCore.updateConfiguration({"yourConfigKey": "yourConfigValue"});
Getting the SDK version:
ACPCore.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPCore version: " + version));
Getting the log level:
ACPCore.getLogLevel().then(level => console.log("AdobeExperienceSDK: Log Level = " + level));
Controlling the log level of the SDK:
import {ACPMobileLogLevel} from '@adobe/react-native-acpcore';

ACPCore.setLogLevel(ACPMobileLogLevel.VERBOSE);
Using the AEP Logging API:
import {ACPMobileLogLevel} from '@adobe/react-native-acpcore';

ACPCore.log(ACPMobileLogLevel.ERROR, "React Native Tag", "React Native Message");

Note: ACPMobileLogLevel contains the following getters:

const ERROR = "ACP_LOG_LEVEL_ERROR";
const WARNING = "ACP_LOG_LEVEL_WARNING";
const DEBUG = "ACP_LOG_LEVEL_DEBUG";
const VERBOSE = "ACP_LOG_LEVEL_VERBOSE";
Getting the current privacy status:
ACPCore.getPrivacyStatus().then(status => console.log("AdobeExperienceSDK: Privacy Status = " + status));
Setting the privacy status:
import {ACPMobilePrivacyStatus} from '@adobe/react-native-acpcore';

ACPCore.setPrivacyStatus(ACPMobilePrivacyStatus.OPT_IN);

Note: ACPMobilePrivacyStatus contains the following getters:

const OPT_IN = "ACP_PRIVACY_STATUS_OPT_IN";
const OPT_OUT = "ACP_PRIVACY_STATUS_OPT_OUT";
const UNKNOWN = "ACP_PRIVACY_STATUS_UNKNOWN";
Getting the SDK identities:
ACPCore.getSdkIdentities().then(identities => console.log("AdobeExperienceSDK: Identities = " + identities));
Dispatching an Event Hub event:
import {ACPExtensionEvent} from '@adobe/react-native-acpcore';

var event = new ACPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchEvent(event);
Dispatching an Event Hub event with callback:
import {ACPExtensionEvent} from '@adobe/react-native-acpcore';

var event = new ACPExtensionEvent("eventName", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchEventWithResponseCallback(event).then(responseEvent => console.log("AdobeExperienceSDK: responseEvent = " + responseEvent));
Dispatching an Event Hub response event:
import {ACPExtensionEvent} from '@adobe/react-native-acpcore';

var responseEvent = new ACPExtensionEvent("responseEvent", "eventType", "eventSource", {"testDataKey": "testDataValue"});
var requestEvent = new ACPExtensionEvent("requestEvent", "eventType", "eventSource", {"testDataKey": "testDataValue"});
ACPCore.dispatchResponseEvent(responseEvent, requestEvent);

Identity

Getting the extension version:
ACPIdentity.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPIdentity version: " + version));
Registering the extension with Core:
ACPIdentity.registerExtension();
Sync Identifiers:
ACPIdentity.syncIdentifiers({"id1": "identifier1"});
Sync Identifiers with Authentication State:
import {ACPMobileVisitorAuthenticationState} from '@adobe/react-native-acpcore';

ACPIdentity.syncIdentifiersWithAuthState({"id1": "identifier1"}, ACPMobileVisitorAuthenticationState.UNKNOWN);

Note: ACPMobileVisitorAuthenticationState contains the following getters:

const AUTHENTICATED = "ACP_VISITOR_AUTH_STATE_AUTHENTICATED";
const LOGGED_OUT = "ACP_VISITOR_AUTH_STATE_LOGGED_OUT";
const UNKNOWN = "ACP_VISITOR_AUTH_STATE_UNKNOWN";
Setting the advertising identifier:
ACPCore.setAdvertisingIdentifier("adID");
Append visitor data to a URL:
ACPIdentity.appendVisitorInfoForURL("test.com").then(urlWithVisitorData => console.log("AdobeExperienceSDK: VisitorData = " + urlWithVisitorData));
Get visitor data as URL query parameter string:
ACPIdentity.getUrlVariables().then(urlVariables => console.log("AdobeExperienceSDK: UrlVariables = " + urlVariables));
Get Identifiers:
ACPIdentity.getIdentifiers().then(identifiers => console.log("AdobeExperienceSDK: Identifiers = " + identifiers));
Get Experience Cloud IDs:
ACPIdentity.getExperienceCloudId().then(cloudId => console.log("AdobeExperienceSDK: CloudID = " + cloudId));
Setting the push identifier:
ACPCore.setPushIdentifier("pushIdentifier");
VisitorID Class:
import {ACPVisitorID} from '@adobe/react-native-acpcore';

var visitorId = new ACPVisitorID(idOrigin?: string, idType: string, id?: string, authenticationState?: ACPMobileVisitorAuthenticationState)

Lifecycle

Getting the extension version:
ACPLifecycle.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPLifecycle version: " + version));
Registering the extension with Core:
ACPLifecycle.registerExtension();
Starting a lifecycle event:
ACPCore.lifecycleStart({"lifecycleStart": "myData"});
Pausing a lifecycle event:
ACPCore.lifecyclePause();

Signal

Getting the extension version:
ACPSignal.extensionVersion().then(version => console.log("AdobeExperienceSDK: ACPSignal version: " + version));
Registering the extension with Core:
ACPSignal.registerExtension();
Collecting PII:
ACPCore.collectPii({"myPii": "data"});

Contributing

See CONTRIBUTING

License

See LICENSE

Keywords

FAQs

Package last updated on 22 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc