Nosferatu's Pace Maker

    @adobe/react-native-aepedgeidentity

    1.0.0 • Public • Published

    React Native Adobe Experience Platform Identity for Edge Network Extension

    npm version npm downloads

    @adobe/react-native-aepedgeidentity is a wrapper around the iOS and Android Adobe Experience Platform Identity for Edge Network Extension to allow for integration with React Native applications.

    Prerequisites

    The Adobe Experience Platform Identity for Edge Network extension has the following peer dependency, which must be installed prior to installing the identity extension:

    Installation

    See Requirements and Installation instructions on the main page

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

    cd MyReactApp
    npm install @adobe/react-native-aepedgeidentity

    Usage

    Installing and registering the extension with the AEP Mobile Core

    The Identity for Edge Network is required for providing the identity information to the Edge Network extension when sending Experience events.

    Install the Identity extension in your mobile property by following the steps in the Identity for Edge Network extension documentation.

    Then follow the same document for registering the Identity extension with the Mobile Core. Note that initializing the SDK should be done in native code, additional documentation on how to initialize the SDK can be found here.

    Initialization Example

    iOS

    // AppDelegate.h
    @import AEPCore;
    @import AEPEdge;
    @import AEPEdgeIdentity;
    ...
    @implementation AppDelegate
    
    // AppDelegate.m
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        [AEPMobileCore setLogLevel: AEPLogLevelDebug];
        [AEPMobileCore registerExtensions:@[AEPMobileEdgeIdentity.class, 
                                            AEPMobileEdge.class] completion:^{
          [AEPMobileCore configureWithAppId:@"yourAppID"];  
        ...   
       }]; 
       return YES;   
     } 
    
    @end

    Android

    import com.adobe.marketing.mobile.LoggingMode;
    import com.adobe.marketing.mobile.MobileCore;
    import com.adobe.marketing.mobile.Edge;
    import com.adobe.marketing.mobile.edge.identity.Identity;  
    ...
    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");
    
        Edge.registerExtension();
        Identity.registerExtension();
        MobileCore.start(new AdobeCallback() {
            @Override
            public void call(Object o) {
            
        }});
      }
    }     

    ℹ️ If your use-case covers both Edge Network and Adobe Experience Cloud Solutions extensions, you need to register Identity for Edge Network and Identity from Mobile Core for Experience Cloud Identity Service extensions. For more details, see the Frequently asked questions.

    Identity for Edge Network

    Importing the extension:

    In your React Native application, import the Identity extension as follows:

    import {Identity} from '@adobe/react-native-aepedgeidentity';

    API reference

    extensionVersion:

    Returns the version of the Identity for Edge Network extension

    Syntax

    extensionVersion(): Promise<string>;

    Example

    Identity.extensionVersion().then(version => console.log("AdobeExperienceSDK: EdgeIdentity version: " + version));

    getExperienceCloudId:

    This API retrieves the ECID that was generated when the app was initially launched. This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall. A promise method which will be invoked once the Experience Cloud ID is available or rejected if an unexpected error occurred or the request timed out.

    Syntax

    getExperienceCloudId(): Promise<string>;

    Example

    Identity.getExperienceCloudId().then(experienceCloudId => console.log("AdobeExperienceSDK: Experience Cloud Id = " + experienceCloudId));

    getIdentities:

    Get all the identities in the Identity for Edge Network extension, including customer identifiers which were previously added. A promise method which will be invoked once the identities are available or rejected if an unexpected error occurred or the request timed out.

    Syntax

    getIdentities(): Promise<IdentityMap>;

    Example

    Identity.getIdentities().then(identities => console.log("AdobeExperienceSDK: Get Identities = " + JSON.stringify(identities)));

    removeIdentity:

    Remove the identity from the stored client-side IdentityMap. The Identity extension will stop sending the identifier to the Edge Network. Using this API does not remove the identifier from the server-side User Profile Graph or Identity Graph.

    Identities with an empty id or namespace are not allowed and are ignored.

    Removing identities using a reserved namespace is not allowed using this API. The reserved namespaces are:

    • ECID
    • IDFA
    • GAID

    Syntax

    removeIdentity(item: IdentityItem, namespace: string);

    Example

    let identityItem  = new IdentityItem("user@example.com");
    Identity.removeIdentity(identityItem, "Email");

    resetIdentity:

    Clears all identities stored in the Identity extension and generates a new Experience Cloud ID (ECID) . Using this API does not remove the identifiers from the server-side User Profile Graph or Identity Graph.

    ℹ️ The Identity for Edge Network extension does not read the Mobile SDK's privacy status and therefor setting the SDK's privacy status to opt-out will not clear the identities from the Identity for Edge Network extension.

    For more details, see theMobileCore.resetIdentities API.

    updateIdentities:

    Update the currently known identities within the SDK. The Identity extension will merge the received identifiers with the previously saved ones in an additive manner, no identities are removed from this API.

    Identities with an empty id or namespace are not allowed and are ignored.

    Updating identities using a reserved namespace is not allowed using this API. The reserved namespaces are:

    • ECID
    • IDFA
    • GAID

    Syntax

    updateIdentities(identityMap: IdentityMap);

    Example

    let identityItem  = new IdentityItem("user@example.com");
    let map = new IdentityMap();
    map.addItem(identityItem, "Email");
    Identity.updateIdentities(map);

    Public Classes

    IdentityMap

    Defines a map containing a set of end user identities, keyed on either namespace integration code or the namespace ID of the identity. The values of the map are an array, meaning that more than one identity of each namespace may be carried. The format of the IdentityMap class is defined by the XDM Identity Map Schema.

    For more information, please read an overview of the AEP Identity Service.

    "identityMap" : {
        "Email" : [
          {
            "id" : "user@example.com",
            "authenticatedState" : "authenticated",
            "primary" : false
          }
        ],
        "Phone" : [
          {
            "id" : "1234567890",
            "authenticatedState" : "ambiguous",
            "primary" : false
          },
          {
            "id" : "5557891234",
            "authenticatedState" : "ambiguous",
            "primary" : false
          }
        ],
        "ECID" : [
          {
            "id" : "44809014977647551167356491107014304096",
            "authenticatedState" : "ambiguous",
            "primary" : true
          }
        ]
      }
    

    Example

    let map = new IdentityMap();
    
    // Add an item
    let identityItem  = new IdentityItem("user@example.com");
    map.addItem(identityItem, "Email");
    
    // Remove an item
    let identityItem  = new IdentityItem("user@example.com");
    map.removeItem(identityItem, "Email");
    
    //Get a list of items for a given namespace
    let namespacecheck = map.getIdentityItemsForNamespace("Email");
    
    //Get a list of all namespaces used in current IdentityMap
    let namespaces = map.getNamespaces();
    
    //Check if IdentityMap has no identities
    let hasNoIdentities = map.isEmpty();

    IdentityItem

    Defines an identity to be included in an IdentityMap.

    The format of the IdentityItem class is defined by the XDM Identity Item Schema.

    Example

    // Initialize
    let item  = new IdentityItem("identifier");
    
    let item  = new IdentityItem("identifier", AuthenticatedState.AUTHENTICATED, false);
    
    //Getters
    let id = item.id;
    let state = item.authenticatedState;
    let primary = item.primary

    AuthenticatedState

    Defines the state an Identity Item is authenticated for.

    The possible authenticated states are:

    • Ambiguous - the state is ambiguous or not defined
    • Authenticated - the user is identified by a login or similar action
    • LoggedOut - the user was identified by a login action at a previous time, but is not logged in now

    Syntax

     export enum AuthenticatedState {
       AUTHENTICATED = 'authenticated',
       LOGGED_OUT = 'loggedOut',
       AMBIGUOUS = 'ambiguous'
     }

    Frequently Asked Questions (FAQ)

    For more details, refer to the frequently asked questions page

    Install

    npm i @adobe/react-native-aepedgeidentity

    DownloadsWeekly Downloads

    194

    Version

    1.0.0

    License

    Apache-2.0

    Unpacked Size

    84.8 kB

    Total Files

    38

    Last publish

    Collaborators

    • adobehalls
    • fullcolorcoder
    • marbec
    • tripod
    • garthdb
    • lazd
    • adobe-admin
    • patrickfulton
    • trieloff
    • shazron
    • krisnye
    • dcpfsdk
    • natebaldwin
    • devongovett
    • aspro83
    • symanovi
    • dpfister
    • stefan-guggisberg
    • korra
    • rofe
    • kptdobe