Skip to content

Commit 9d30060

Browse files
Update Readme.md
1 parent 9fc6c22 commit 9d30060

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

Readme.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Built with AppsFlyer Android SDK `v6.13.0`
3232
- [Register In-App Events](#adding_events)
3333
- [Get Conversion Data](#conversion_data)
3434
- [Unified Deep Linking](#deep_linking)
35+
- [Send consent for DMA compliance](#dma_support)
3536
- [Sample App](#sample_app)
3637

3738

@@ -70,6 +71,7 @@ AppsFlyer supports the `identify` and `track` methods.
7071
### <a id="manual">
7172
# Manual mode
7273
Starting version 6.8.0, we support a manual mode to seperate the initialization of the AppsFlyer SDK and the start of the SDK. In this case, the AppsFlyer SDK won't start automatically, giving the developper more freedom when to start the AppsFlyer SDK. Please note that in manual mode, the developper is required to implement the API startAppsFlyer(Context context) in order to start the SDK.
74+
<br>If you are using CMP to collect consent data this feature is needed. See explanation [here](#dma_support).
7375
### Example:
7476

7577
```java
@@ -252,6 +254,97 @@ In order to implement unified deep linking, call the method below :
252254
```
253255
For more information about unified deep linking, check [here](https://dev.appsflyer.com/docs/android-unified-deep-linking)
254256

257+
## <a id="dma_support"> Send consent for DMA compliance
258+
For a general introduction to DMA consent data, see [here](https://dev.appsflyer.com/hc/docs/send-consent-for-dma-compliance).<be>
259+
The SDK offers two alternative methods for gathering consent data:<br>
260+
- **Through a Consent Management Platform (CMP)**: If the app uses a CMP that complies with the [Transparency and Consent Framework (TCF) v2.2 protocol](https://iabeurope.eu/tcf-supporting-resources/), the SDK can automatically retrieve the consent details.<br>
261+
<br>OR<br><br>
262+
- **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.
263+
### Use CMP to collect consent data
264+
A CMP compatible with TCF v2.2 collects DMA consent data and stores it in <code>SharedPreferences</code>. To enable the SDK to access this data and include it with every event, follow these steps:<br>
265+
<ol>
266+
<li> Call <code>AppsFlyerLib.getInstance().enableTCFDataCollection(true)</code> to instruct the SDK to collect the TCF data from the device.
267+
<li> Set the the adapter to be manual : <code>AppsflyerIntegration.setManualMode(true)</code>. <br> This will allow us to delay the Conversion call in order to provide the SDK with the user consent.
268+
<li> Initialize Segment using <code>AppsflyerIntegration.FACTORY</code>.
269+
<li> In the <code>Activity</code> class, use the CMP to decide if you need the consent dialog in the current session.
270+
<li> If needed, show the consent dialog, using the CMP, to capture the user consent decision. Otherwise, go to step 6.
271+
<li> Get confirmation from the CMP that the user has made their consent decision, and the data is available in <code>SharedPreferences</code>.
272+
<li> Call <code>AppsflyerIntegration.startAppsFlyer(this)</code>
273+
</ol>
274+
275+
#### Application class
276+
``` kotlin
277+
@Override public void onCreate() {
278+
super.onCreate();
279+
AppsFlyerLib.getInstance().enableTCFDataCollection(true);
280+
AppsflyerIntegration.setManualMode(true);
281+
initSegmentAnalytics();
282+
}
283+
284+
private void initSegmentAnalytics() {
285+
Analytics.Builder builder = new Analytics.Builder(this, SEGMENT_WRITE_KEY)
286+
.use(AppsflyerIntegration.FACTORY)
287+
.logLevel(Analytics.LogLevel.VERBOSE)
288+
.trackApplicationLifecycleEvents() // Enable this to record certain application events automatically!
289+
.recordScreenViews(); // Enable this to record screen views automatically!
290+
// Set the initialized instance as a globally accessible instance.
291+
Analytics.setSingletonInstance(builder.build());
292+
}
293+
```
294+
#### Activity class
295+
```kotlin
296+
public class MainActivity extends AppCompatActivity {
297+
298+
private boolean consentRequired = true;
299+
@Override
300+
protected void onCreate(Bundle savedInstanceState) {
301+
super.onCreate(savedInstanceState);
302+
setContentView(R.layout.activity_main);
303+
if (consentRequired)
304+
initConsentCollection();
305+
else
306+
AppsflyerIntegration.startAppsFlyer(this);
307+
}
308+
309+
private void initConsentCollection() {
310+
// Implement here the you CMP flow
311+
// When the flow is completed and consent was collected
312+
// call onConsentCollectionFinished()
313+
}
314+
315+
private void onConsentCollectionFinished() {
316+
AppsflyerIntegration.startAppsFlyer(this);
317+
}
318+
}
319+
```
320+
321+
322+
### Manually collect consent data
323+
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.
324+
<ol>
325+
<li> Initialize <code>AppsFlyerIntegration</code> using manual mode and also <code>Analytics</code>. This will allow us to delay the Conversion call in order to provide the SDK with the user consent.
326+
<li> In the <code>Activity</code> class, determine whether the GDPR applies or not to the user.<br>
327+
- If GDPR applies to the user, perform the following:
328+
<ol>
329+
<li> Given that GDPR is applicable to the user, determine whether the consent data is already stored for this session.
330+
<ol>
331+
<li> If there is no consent data stored, show the consent dialog to capture the user consent decision.
332+
<li> If there is consent data stored continue to the next step.
333+
</ol>
334+
<li> To transfer the consent data to the SDK create an object called <code>AppsFlyerConsent</code> using the <code>forGDPRUser()</code> method with the following parameters:<br>
335+
- <code>hasConsentForDataUsage</code> - Indicates whether the user has consented to use their data for advertising purposes.<br>
336+
- <code>hasConsentForAdsPersonalization</code> - Indicates whether the user has consented to use their data for personalized advertising purposes.
337+
<li> Call <code>AppsFlyerLib.getInstance().setConsentData()</code> with the <code>AppsFlyerConsent</code> object.
338+
<li> Call <code>AppsflyerIntegration.startAppsFlyer(this)</code>.
339+
</ol><br>
340+
- If GDPR doesn’t apply to the user perform the following:
341+
<ol>
342+
<li> Create an <code>AppsFlyerConsent</code> object using the <code>forNonGDPRUser()</code> method. This method doesn’t accept any parameters.
343+
<li> Call <code>AppsFlyerLib.getInstance().setConsentData()</code> with the <code>AppsFlyerConsent</code> object.
344+
<li> Call <code>AppsflyerIntegration.startAppsFlyer(this)</code>.
345+
</ol>
346+
</ol>
347+
255348
### <a id="sample_app">
256349

257350
## Sample App

0 commit comments

Comments
 (0)