React-native

https://www.npmjs.com/package/appconsent-reactnative

AppConsent for React Native

  • iOS Framework: 1.2.13

  • Android Sdk UI: 1.1.5

Important AppConsent SDK supports the new App Tracking Transparency framework (> iOS 14+ available).You must register the NSUserTrackingUsageDescription key in your Info.plist of your application otherwise your app will crash.

Getting started

  • make sure to setup the environment for react-native like explained here.

  • $ npm install appconsent-reactnative --save

  • iOS : Don't forget to run pod install.

  • Android : Don't forget to add in your project/build.gradle this maven url in the allprojects/repositories block like this :

allprojects {
repositories {
maven {
url "https://artifactory.datalf.chat/artifactory/app-consent-v2-release"
}
}
}

iOS Documentation

You can find the documentation of iOS here.

Android Documentation

You can find the Documentation of Android here.

Usage

import AppConsent from 'appconsent-reactnative';
// Configure at launch (appKey:forceApplyGDPR:forceATT)
AppConsent.configureWith("appKey", true, true);

Features of AppConsent

AppConsent.consentAlreadyGiven()
.then( success =>
console.log("🔥 consentAlreadyGiven => " + success)
)

Return true if consent is given, false otherwise.

Present notice

AppConsent.present(true)

To display AppConsent UI by modal on top of your view.

present(false) display introduction page first.

Get App Key

AppConsent.getAppKey()
.then( success =>
console.log("🔥 getAppKey => " + success)
)

Return AppKey.

Get Force Apply GDPR

AppConsent.getForceApplyGDPR()
.then( success =>
console.log("🔥 getForceApplyGDPR => " + success)
)

Return forceApplyGDPR => true or false.

Get Force ATT - iOS Only

AppConsent.getForceATT()
.then( success =>
console.log("🔥 getForceATT => " + success)
)

Return forceATT => true or false.

AppConsent.consentGiven()
.then( success =>
console.log("🔥 consentGiven => " + success)
)

Callback when user give its consent.

Consentable allowed - objectId

AppConsent.consentableAllowedByObjectId("1")
.then( success =>
console.log("🔥 consentableAllowedByObjectId => " + success)
)

Return true if consentable with objectId = 1 is allowed, false otherwise.

Consentable allowed - iabId

AppConsent.consentableAllowedByIABId("1", 1)
.then( success =>
console.log("🔥 consentableAllowedByIABId => " + success)
)

Params: iabId is a String type is a NSInteger (0: purpose ,1: feature , 2: specialFeature ,3: specialPurpose )

Return true if consentable with iabId = 1 is allowed, false otherwise.

Consentable allowed - extraId

AppConsent.extraConsentableAllowed("1")
.then( success =>
console.log("🔥 extraConsentableAllowed => " + success)
)

Return true if consentable with extraId = 1 is allowed, false otherwise.

Stack allowed - iabId

AppConsent.stackAllowedByIABId("1")
.then( success =>
console.log("🔥 stackAllowedByIABId => " + success)
)

Return true if stack with iabId = 1 is allowed, false otherwise.

Vendor allowed - iabId

AppConsent.vendorAllowedByIABId("1")
.then( success =>
console.log("🔥 vendorAllowedByIABId => " + success)
)

Return true if vendor with iabId = 1 is allowed, false otherwise.

Vendor allowed - extraId

AppConsent.extraVendorAllowed("1")
.then( success =>
console.log("🔥 extraVendorAllowed => " + success)
)

Return true if vendor with extraId = 1 is allowed, false otherwise.

AppConsent.setConsentableConsent({"1":1})
.then( success =>
console.log("🔥 setConsentableConsent => " + "Success")
)

Set consentables status with an iabId.

Warning Key must be an iabId, not an objectId. Value must be an Integer: 0 (pending), 1 (allowed), -1 (denied)

Note this method doesn’t send request to the server.

AppConsent.setExtraConsentableConsent({"TDWLFix3":1})
.then( success =>
console.log("🔥 setExtraConsentableConsent => " + "Success")
)

Set consentbles status with extraId.

Warning Key must be an extraId, not an objectId. Value must be an Integer: 0 (pending), 1 (allowed), -1 (denied)

Note this method doesn’t send request to the server.

Check for update

AppConsent.checkForUpdate()
.then( success =>
console.log("🔥 checkForUpdate => " + success)
)

Check if consent must be updated (new gvl version, new consentables…)

Clear consents

AppConsent.clearConsent()

Clear consents on NSUserDefaults, but not on server.

Is GDPR Country

AppConsent.isGDPRCountry()
.then( success =>
console.log("🔥 isGDPRCountry => " + success)
)

Check if device is GDPR country.

Return true, false otherwise.

App Tracking is available - iOS Only

AppConsent.appTrackingIsAvailable()
.then( success =>
console.log("🔥 appTrackingIsAvailable => " + success)
)

Check if your device supports App Tracking Transparency.

Return true if available, false otherwise.

App Tracking Authorization Given - iOS Only

AppConsent.appTrackingAuthorizationGiven()
.then( success =>
console.log("🔥 appTrackingAuthorizationGiven => " + success)
)

Check if App Tracking Transparency has been given.

Return 0 (not given), 1 (given), 2 (not supported)

App Tracking Authorization Status - iOS Only

AppConsent.appTrackingAuthorizationStatus()
.then( success =>
console.log("🔥 appTrackingAuthorizationStatus => " + success)
)

Check status of App Tracking Transparency.

Return 0 (failure), 1 (success), 2 (not supported)

Floating purpose allowed - extraId

AppConsent.extraFloatingPurposeAllowed("NkDawTu1")
.then( success =>
console.log("🔥 extraFloatingPurposeAllowed => " + success)
)

Check if floating purpose is allowed. Note: You need to call checkForUpdate method before call this above method to stay up to date.