New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@adobe/react-native-aepedgeconsent

Package Overview
Dependencies
Maintainers
24
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adobe/react-native-aepedgeconsent

Adobe Experience Platform Consent Collection extension for AEP Mobile SDK. Written and maintained by Adobe.

  • 6.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
24
Created
Source

npm version npm downloads

@adobe/react-native-aepedgeconsent is a wrapper for the iOS and Android Consent for Edge Network extension to allow for integration with React Native applications.

Prerequisites

The Consent for Edge Network extension has the following peer dependency, which must be installed prior to installing the Consent extension:

  • Core

Installation

See Requirements and Installation instructions on the main page.

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

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

Usage

Installing and registering the extension with the AEP Mobile Core

Install the Consent extension in your mobile property and configure the default consent preferences by following the steps in the Consent for Edge Network extension documentation.

Then follow the same document for registering the Consent 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;
@import AEPEdgeConsent;
...
@implementation AppDelegate

// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // TODO: Set up the preferred Environment File ID from your mobile property configured in Data Collection UI
    NSString* ENVIRONMENT_FILE_ID = @"YOUR-APP-ID";

    NSArray *extensionsToRegister = @[AEPMobileEdgeIdentity.class, 
                                      AEPMobileEdge.class, 
                                      AEPMobileEdgeConsent.class
                                      ];

    [AEPMobileCore registerExtensions:extensionsToRegister completion:^{
      [AEPMobileCore configureWithAppId: ENVIRONMENT_FILE_ID];  
    ...   
  }]; 
   return YES;   
 } 

@end

Android

import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Edge;
import com.adobe.marketing.mobile.edge.identity.Identity;
import com.adobe.marketing.mobile.edge.consent.Consent;
  
...
import android.app.Application;
...
public class MainApplication extends Application implements ReactApplication {
  ...
  // TODO: Set up the preferred Environment File ID from your mobile property configured in Data Collection UI
  private final String ENVIRONMENT_FILE_ID = "YOUR-APP-ID";

  @Override
  public void on Create(){
    super.onCreate();
    ...
    MobileCore.setApplication(this);
    MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID);

    MobileCore.registerExtensions(
    Arrays.asList(Consent.EXTENSION, Identity.EXTENSION, Edge.EXTENSION),
    o -> Log.d("MainApp", "Adobe Experience Platform Mobile SDK was initialized")
    );
  }
}  

Importing the extension

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

import {Consent} from "@adobe/react-native-aepedgeconsent";

API reference

extensionVersion

Returns the version of the Consent extension

Syntax

extensionVersion(): Promise<string>

Example

Consent.extensionVersion().then(version => console.log("Consent.extensionVersion: " + version));

getConsents

Retrieves the current consent preferences stored in the Consent extension and resolves the promise with the current consent preferences or rejects it if an unexpected error occurs or the request timed out. Output example: {"consents": {"collect": {"val": "y"}}}

Syntax

getConsents(): Promise<Record<string, any>>

Example

Consent.getConsents().then(consents => {
  console.log("AEPConsent.getConsents returned current consent preferences:  " + JSON.stringify(consents));
}).catch((error) => {
  console.warn("AEPConsent.getConsents returned error: ", error.message);
});

update

Merges the existing consents with the given consents. Duplicate keys will take the value of those passed in the API. Input example: {"consents": {"collect": {"val": "y"}}}

Syntax

update(consents: Record<string, any>) 

Example

var consents: {[keys: string]: any} = {"consents" : {"collect" : {"val": "y"}}};
Consent.update(consents);

Keywords

FAQs

Package last updated on 06 Jun 2024

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