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 :
1
allprojects {
2
repositories {
3
maven {
4
url "https://artifactory.datalf.chat/artifactory/app-consent-v2-release"
5
}
6
}
7
}
Copied!

iOS Documentation

You can find the documentation of iOS here.

Android Documentation

You can find the Documentation of Android here.

Usage

1
import AppConsent from 'appconsent-reactnative';
2
3
// Configure at launch (appKey:forceApplyGDPR:forceATT)
4
AppConsent.configureWith("appKey", true, true);
Copied!

Features of AppConsent

1
AppConsent.consentAlreadyGiven()
2
.then( success =>
3
console.log("🔥 consentAlreadyGiven => " + success)
4
)
Copied!
Return true if consent is given, false otherwise.

Present notice

1
AppConsent.present(true)
Copied!
To display AppConsent UI by modal on top of your view.
present(false) display introduction page first.

Get App Key

1
AppConsent.getAppKey()
2
.then( success =>
3
console.log("🔥 getAppKey => " + success)
4
)
Copied!
Return AppKey.

Get Force Apply GDPR

1
AppConsent.getForceApplyGDPR()
2
.then( success =>
3
console.log("🔥 getForceApplyGDPR => " + success)
4
)
Copied!
Return forceApplyGDPR => true or false.

Get Force ATT - iOS Only

1
AppConsent.getForceATT()
2
.then( success =>
3
console.log("🔥 getForceATT => " + success)
4
)
Copied!
Return forceATT => true or false.
1
AppConsent.consentGiven()
2
.then( success =>
3
console.log("🔥 consentGiven => " + success)
4
)
Copied!
Callback when user give its consent.

Consentable allowed - objectId

1
AppConsent.consentableAllowedByObjectId("1")
2
.then( success =>
3
console.log("🔥 consentableAllowedByObjectId => " + success)
4
)
Copied!
Return true if consentable with objectId = 1 is allowed, false otherwise.

Consentable allowed - iabId

1
AppConsent.consentableAllowedByIABId("1", 1)
2
.then( success =>
3
console.log("🔥 consentableAllowedByIABId => " + success)
4
)
Copied!
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

1
AppConsent.extraConsentableAllowed("1")
2
.then( success =>
3
console.log("🔥 extraConsentableAllowed => " + success)
4
)
Copied!
Return true if consentable with extraId = 1 is allowed, false otherwise.

Stack allowed - iabId

1
AppConsent.stackAllowedByIABId("1")
2
.then( success =>
3
console.log("🔥 stackAllowedByIABId => " + success)
4
)
Copied!
Return true if stack with iabId = 1 is allowed, false otherwise.

Vendor allowed - iabId

1
AppConsent.vendorAllowedByIABId("1")
2
.then( success =>
3
console.log("🔥 vendorAllowedByIABId => " + success)
4
)
Copied!
Return true if vendor with iabId = 1 is allowed, false otherwise.

Vendor allowed - extraId

1
AppConsent.extraVendorAllowed("1")
2
.then( success =>
3
console.log("🔥 extraVendorAllowed => " + success)
4
)
Copied!
Return true if vendor with extraId = 1 is allowed, false otherwise.
1
AppConsent.setConsentableConsent({"1":1})
2
.then( success =>
3
console.log("🔥 setConsentableConsent => " + "Success")
4
)
Copied!
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.
1
AppConsent.setExtraConsentableConsent({"TDWLFix3":1})
2
.then( success =>
3
console.log("🔥 setExtraConsentableConsent => " + "Success")
4
)
Copied!
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

1
AppConsent.checkForUpdate()
2
.then( success =>
3
console.log("🔥 checkForUpdate => " + success)
4
)
Copied!
Check if consent must be updated (new gvl version, new consentables…)

Clear consents

1
AppConsent.clearConsent()
Copied!
Clear consents on NSUserDefaults, but not on server.

Is GDPR Country

1
AppConsent.isGDPRCountry()
2
.then( success =>
3
console.log("🔥 isGDPRCountry => " + success)
4
)
Copied!
Check if device is GDPR country.
Return true, false otherwise.

App Tracking is available - iOS Only

1
AppConsent.appTrackingIsAvailable()
2
.then( success =>
3
console.log("🔥 appTrackingIsAvailable => " + success)
4
)
Copied!
Check if your device supports App Tracking Transparency.
Return true if available, false otherwise.

App Tracking Authorization Given - iOS Only

1
AppConsent.appTrackingAuthorizationGiven()
2
.then( success =>
3
console.log("🔥 appTrackingAuthorizationGiven => " + success)
4
)
Copied!
Check if App Tracking Transparency has been given.
Return 0 (not given), 1 (given), 2 (not supported)

App Tracking Authorization Status - iOS Only

1
AppConsent.appTrackingAuthorizationStatus()
2
.then( success =>
3
console.log("🔥 appTrackingAuthorizationStatus => " + success)
4
)
Copied!
Check status of App Tracking Transparency.
Return 0 (failure), 1 (success), 2 (not supported)

Floating purpose allowed - extraId

1
AppConsent.extraFloatingPurposeAllowed("NkDawTu1")
2
.then( success =>
3
console.log("🔥 extraFloatingPurposeAllowed => " + success)
4
)
Copied!
Check if floating purpose is allowed. Note: You need to call checkForUpdate method before call this above method to stay up to date.
Last modified 4mo ago