Send consent for DMA compliance
Send consent for DMA compliance
The SDK offers two alternative methods for gathering consent data:
Through a Consent Management Platform (CMP): If the app uses a CMP that complies with the Transparency and Consent Framework (TCF) v2.2 protocol, the SDK can automatically retrieve the consent details.
OR
Through a dedicated SDK API: Developers can pass Google's required consent data directly to the SDK using a specific API designed for this purpose.
Use CMP to collect consent data
A CMP compatible with TCF v2.2 collects DMA consent data and stores it in NSUserDefaults (iOS) and SharedPreferences (Android). To enable the SDK to access this data and include it with every event, follow these steps:
- Call
appsFlyer.enableTCFDataCollection(true)
- Initialize the SDK in manual start mode
- Use the CMP to decide if you need the consent dialog in the current session to acquire the consent data. If you need the consent dialog move to step 4; otherwise move to step 5
- Get confirmation from the CMP that the user has made their consent decision and the data is available in NSUserDefaults/SharedPreferences
- Call
appsFlyer.startSdk()
useEffect(() => {
const option = {
isDebug: true,
devKey: 'UxXxXxXxXd',
onInstallConversionDataListener: true,
onDeepLinkListener: true,
timeToWaitForATTUserAuthorization: 10,
manualStart: true, // <-- Manual start
};
// TCF data collection
appsFlyer.enableTCFDataCollection(true);
//init appsflyer
appsFlyer.initSdk(
option,
res => {
console.log(res);
},
err => {
console.log(err);
},
);
...
// CMP Pseudocode
if (cmpManager.hasConsent()) {
appsFlyer.startSdk();
} else {
cmpManager.presentConsentDialog(res => {
appsFlyer.startSdk();
});
}
},[])
Manually collect consent data
If your app does not use a CMP compatible with TCF v2.2, use the SDK API detailed below to provide the consent data directly to the SDK.
When GDPR applies to the user
If GDPR applies to the user, perform the following:
- Given that GDPR is applicable to the user, determine whether the consent data is already stored for this session.
- If there is no consent data stored, show the consent dialog to capture the user consent decision.
- If there is consent data stored continue to the next step.
- To transfer the consent data to the SDK create an AppsFlyerConsent object using
forGDPRUser
method that accepts the following parameters:
hasConsentForDataUsage: boolean
- Indicates whether the user has consented to use their data for advertising purposes.
hasConsentForAdsPersonalization: boolean
- Indicates whether the user has consented to use their data for personalized advertising. - Call
appsFlyer.setConsentData(consentData)
with the AppsFlyerConsent object. - Call
appsFlyer.initSdk()
.
import appsFlyer, {AppsFlyerConsent} from 'react-native-appsflyer';
useEffect(() => {
const option = {
isDebug: true,
devKey: 'UxXxXxXxXd',
onInstallConversionDataListener: true,
onDeepLinkListener: true,
timeToWaitForATTUserAuthorization: 10,
};
// user consent data
let consentData = AppsFlyerConsent.forGDPRUser(true, false);
appsFlyer.setConsentData(consentData);
//start appsflyer
appsFlyer.initSdk(
option,
res => {
console.log(res);
},
err => {
console.log(err);
},
);
},[])
When GDPR does not apply to the user
If GDPR doesn’t apply to the user perform the following:
- Create an AppsFlyerConsent object using
forNonGDPRUser
method that doesn't accepts any parameters - Call
appsFlyer.setConsentData(consentData)
with the AppsFlyerConsent object. - Call
appsFlyer.initSdk()
.
import appsFlyer, {AppsFlyerConsent} from 'react-native-appsflyer';
useEffect(() => {
const option = {
isDebug: true,
devKey: 'UxXxXxXxXd',
onInstallConversionDataListener: true,
onDeepLinkListener: true,
timeToWaitForATTUserAuthorization: 10,
};
// GDPR does not apply to the user
let consentData = AppsFlyerConsent.forNonGDPRUser();
appsFlyer.setConsentData(consentData);
//start appsflyer
appsFlyer.initSdk(
option,
res => {
console.log(res);
},
err => {
console.log(err);
},
);
},[])
Updated 9 months ago