npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adobe/react-native-aeptarget

v6.0.2

Published

Adobe Experience Platform support for React Native apps.

Downloads

16,573

Readme

React Native AEP Target Extension

npm version npm downloads

@adobe/react-native-aeptarget is a wrapper around the iOS and Android AEP Target SDK to allow integration with React Native applications.

Peer Dependencies

The Adobe Experience Platform Target extension has the following peer dependency, which must be installed prior to installing the target extension:

Installation

See Requirements and Installation instructions on the main page

Install the @adobe/react-native-aeptarget package:

NPM:

npm install @adobe/react-native-aeptarget

Yarn:

yarn add @adobe/react-native-aeptarget

Usage

Initializing and registering the extension

Initialization of the SDK should be done in native code, documentation on how to initialize the SDK can be found here.

Example:

iOS

@import AEPCore;
@import AEPLifecycle;
@import AEPEdge;
@import AEPTarget;

@implementation AppDelegate
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [AEPMobileCore setLogLevel: AEPLogLevelDebug];
  [AEPMobileCore configureWithAppId:@"yourAppID"];

  const UIApplicationState appState = application.applicationState;

  [AEPMobileCore registerExtensions: @[AEPMobileEdge.class, AEPMobileTarget.class] completion:^{
    if (appState != UIApplicationStateBackground) {
       [AEPMobileCore lifecycleStart:nil];
    }
  }];
  return YES;
}
@end

Android

import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.InvalidInitException;
import com.adobe.marketing.mobile.Lifecycle;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Edge;
import com.adobe.marketing.mobile.Target;

...
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(
                Edge.EXTENSION,
                Target.EXTENSION);
    MobileCore.registerExtensions(extensions, o -> {
      MobileCore.lifecycleStart(null);
    });
  }
}

Importing the extension:

import {
  Target,
  TargetOrder,
  TargetParameters,
  TargetPrefetchObject,
  TargetProduct,
  TargetRequestObject,
} from "@adobe/react-native-aeptarget";

API Reference

Getting the extension version:

Syntax

extensionVersion(): Promise<string>

Example

const version = await Target.extensionVersion();
console.log("AdobeExperienceSDK: AEPTarget version: " + version);

Get custom visitor IDs:

Syntax

getThirdPartyId(): Promise<string>

Example

const id = await Target.getThirdPartyId();
console.log("AdobeExperienceSDK: Third Party ID: " + id);

Set custom visitor IDs:

Syntax

setThirdPartyId(<id>): void

Example

Target.setThirdPartyId("thirdPartyId");

Reset user experience:

Syntax

resetExperience(): void

Example

Target.resetExperience();

Get Target Session ID:

Syntax

getSessionId(): Promise<string>

Example

const id = await Target.getSessionId();
console.log("AdobeExperienceSDK: Session ID " + id);

Get Target user identifier:

Syntax

getTntId(): Promise<string>

Example

const id = await Target.getTntId();
console.log("AdobeExperienceSDK: TNT ID " + id);

Load Target requests:

Syntax

retrieveLocationContent(Array<TargetRequestObject>, <TargetParameters>): void

Example

var mboxParameters1 = { status: "platinum" };
var mboxParameters2 = { userType: "Paid" };
var purchaseIDs = ["34", "125"];

var targetOrder = new TargetOrder("ADCKKIM", 344.3, purchaseIDs);
var targetProduct = new TargetProduct("24D3412", "Books");
var parameters1 = new TargetParameters(mboxParameters1, null, null, null);
var request1 = new TargetRequestObject(
  "mboxName2",
  parameters1,
  "defaultContent1",
  (error, content) => {
    if (error) {
      console.error(error);
    } else {
      console.log("Adobe content:" + content);
    }
  }
);

var parameters2 = new TargetParameters(
  mboxParameters1,
  { profileParameters: "parameterValue" },
  targetProduct,
  targetOrder
);
var request2 = new TargetRequestObject(
  "mboxName2",
  parameters2,
  "defaultContent2",
  (error, content) => {
    if (error) {
      console.error(error);
    } else {
      console.log("Adobe content:" + content);
    }
  }
);

var locationRequests = [request1, request2];
var profileParameters1 = { ageGroup: "20-32" };

var parameters = new TargetParameters(
  { parameters: "parametervalue" },
  profileParameters1,
  targetProduct,
  targetOrder
);
Target.retrieveLocationContent(locationRequests, parameters);

Using the prefetch APIs:

Syntax

prefetchContent(Array<TargetPrefetchObject>, <TargetParameters>): Promise<any>

Example

var mboxParameters1 = { status: "platinum" };
var mboxParameters2 = { userType: "Paid" };
var purchaseIDs = ["34", "125"];

var targetOrder = new TargetOrder("ADCKKIM", 344.3, purchaseIDs);
var targetProduct = new TargetProduct("24D3412", "Books");
var parameters1 = new TargetParameters(mboxParameters1, null, null, null);
var prefetch1 = new TargetPrefetchObject("mboxName2", parameters1);

var parameters2 = new TargetParameters(
  mboxParameters1,
  { profileParameters: "parameterValue" },
  targetProduct,
  targetOrder
);
var prefetch2 = new TargetPrefetchObject("mboxName2", parameters2);

var prefetchList = [prefetch1, prefetch2];
var profileParameters1 = { ageGroup: "20-32" };

var parameters = new TargetParameters(
  { parameters: "parametervalue" },
  profileParameters1,
  targetProduct,
  targetOrder
);
Target.prefetchContent(prefetchList, parameters)
  .then((success) => console.log(success))
  .catch((err) => console.log(err));

Set Session ID

Syntax

Target.setSessionId(<sessionId>): void

Example

Target.setSessionId("sessionId");

Set TNT ID

Syntax

Target.setTntId(<tntId>): void

Example

Target.setTntId("tntId");

Set preview restart deep link:

Syntax

setPreviewRestartDeeplink(<deeplink>): void;

Example

Target.setPreviewRestartDeeplink("https://www.adobe.com");

Send an mbox click notification:

Syntax

clickedLocation(<locationName>, <TargetParameters>): void;

Example

var purchaseIDs = ["34", "125"];

var targetOrder = new TargetOrder("ADCKKIM", 344.3, purchaseIDs);
var targetProduct = new TargetProduct("24D3412", "Books");
var profileParameters1 = { ageGroup: "20-32" };
var parameters = new TargetParameters(
  { parameters: "parametervalue" },
  profileParameters1,
  targetProduct,
  targetOrder
);

Target.clickedLocation("locationName", parameters);

Send an mbox location displayed notification:

Syntax

displayedLocations(Array<string>, <TargetParameters>): void;

Example

var purchaseIDs = ["34", "125"];

var targetOrder = new TargetOrder("ADCKKIM", 344.3, purchaseIDs);
var targetProduct = new TargetProduct("24D3412", "Books");
var profileParameters1 = { ageGroup: "20-32" };
var parameters = new TargetParameters(
  { parameters: "parametervalue" },
  profileParameters1,
  targetProduct,
  targetOrder
);

Target.displayedLocations(["locationName", "locationName1"], parameters);

TargetPrefetchObject:

The Target extension exports a class TargetPrefetchObject.

constructor(name?: string, targetParameters?: TargetParameters);

TargetRequestObject:

The Target extension exports a class TargetRequestObject, which extends TargetPrefetchObject.

constructor(name: string, targetParameters: TargetParameters, defaultContent: string);

TargetOrder:

The Target extension exports a class TargetOrder.

constructor(orderId: string, total?: number, purchasedProductIds: Array<string>);

TargetProduct:

The Target extension exports a class TargetOrder.

constructor(productId: string, categoryId: string);

TargetParameters:

The Target extension exports a class TargetParameters.

constructor(parameters?: Record<string, string>, profileParameters?: Record<string, string>, product?: TargetProduct, order?: TargetOrder);