3.0.0 • Published 5 months ago

@essent/nativescript-adobe-experience-cloud v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Adobe Experience Cloud for NativeScript

npm install @essent/nativescript-adobe-experience-cloud --save

This plugin provides the Adobe Experience Platform

https://github.com/Adobe-Marketing-Cloud/acp-sdks/releases Get the Adobe Experience Platform SDK https://aep-sdks.gitbook.io/docs/getting-started/get-the-sdk

Setting up the application for usage with this plugin.

Setup config.ts

Create a configuration file and place your ENVIRONMENT_ID from Adobe Experience platform.

import { AdobeAnalyticsSettings } from "@essent/nativescript-adobe-experience-cloud";

export const adobeExperienceSettings: AdobeAnalyticsSettings = {
    environmentId: 'Put your environment id here.',
    debug: true
};

Initialize SDK

Android

import { AdobeAnalytics } from '@essent/nativescript-adobe-experience-cloud';
import { adobeExperienceSettings } from './config'; 

@NativeClass()
@JavaProxy('nl.essent.Application')
class Application extends android.app.Application {

    public onCreate(): void {
        super.onCreate();
        AdobeAnalytics.getInstance().initSdk(adobeExperienceSettings, this);
    }

    public attachBaseContext(baseContext: android.content.Context) {
        super.attachBaseContext(baseContext);
    }
}

IOS

import { AdobeAnalytics } from '@essent/nativescript-adobe-experience-cloud';
import { adobeExperienceSettings } from './config'; 

@NativeClass()
class MyDelegate extends UIResponder implements UIApplicationDelegate {
    public static ObjCProtocols = [UIApplicationDelegate];

    applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary<string, any>): boolean {
        AdobeAnalytics.getInstance().initSdk(adobeExperienceSettings, application);
        return true;
     }
 }
    ios.delegate = MyDelegate;

NOTE This plugin provides only initial set of extensions registered with Adobe Experience platform. For any additional extension fork this plugin and configure based on Mobile Property installation instructions.

Enable lifecycle tracking

Android

With onResume function start Lifecycle data collection:

import {AdobeAnalytics} from "@essent/nativescript-adobe-experience-cloud";

public onResume() : void {
        AdobeAnalytics.getInstance().resumeCollectingLifecycleData();
        super.onResume();
    }
}

Use onPause function to pause collection Lifecycle data:

public onPause() : void {
        AdobeAnalytics.getInstance().pauseCollectingLifecycleData();
        super.onPause();
    }

IOS

Start collection Lifecycle data is part of plugin implementation called during initialization of SDK.

When application is resuming from background state, you need to resume collection of Lifecycle data:

applicationWillEnterForeground(application: UIApplication){
    AdobeAnalytics.getInstance().resumeCollectingLifecycleData();
 }

When the app enters the background, pause collecting Lifecycle data:

applicationDidEnterBackground(application: UIApplication): void {
    AdobeAnalytics.getInstance().pauseCollectingLifecycleData();
}

Track states and actions

States and actions can be traced through method calls that match their native counterparts signature.

Privacy options

See: https://marketing.adobe.com/resources/help/en_US/mobile/ios/privacy.html

Select a privacy option:

Send Data Until Opt-Out

AdobeAnalytics.getInstance().optIn();

Hold Data Until Opt-In

AdobeAnalytics.getInstance().optOut();