From 9d30060558632b713647eeee5998c95ecf1efefc Mon Sep 17 00:00:00 2001 From: morisgateno-appsflyer <121490279+morisgateno-appsflyer@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:07:37 +0200 Subject: [PATCH] Update Readme.md --- Readme.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/Readme.md b/Readme.md index 295ccf8..3b7efc5 100644 --- a/Readme.md +++ b/Readme.md @@ -32,6 +32,7 @@ Built with AppsFlyer Android SDK `v6.13.0` - [Register In-App Events](#adding_events) - [Get Conversion Data](#conversion_data) - [Unified Deep Linking](#deep_linking) +- [Send consent for DMA compliance](#dma_support) - [Sample App](#sample_app) @@ -70,6 +71,7 @@ AppsFlyer supports the `identify` and `track` methods. ### # Manual mode 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. +
If you are using CMP to collect consent data this feature is needed. See explanation [here](#dma_support). ### Example: ```java @@ -252,6 +254,97 @@ In order to implement unified deep linking, call the method below : ``` For more information about unified deep linking, check [here](https://dev.appsflyer.com/docs/android-unified-deep-linking) +##
Send consent for DMA compliance +For a general introduction to DMA consent data, see [here](https://dev.appsflyer.com/hc/docs/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](https://iabeurope.eu/tcf-supporting-resources/), 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 SharedPreferences. To enable the SDK to access this data and include it with every event, follow these steps:
+
    +
  1. Call AppsFlyerLib.getInstance().enableTCFDataCollection(true) to instruct the SDK to collect the TCF data from the device. +
  2. Set the the adapter to be manual : AppsflyerIntegration.setManualMode(true).
    This will allow us to delay the Conversion call in order to provide the SDK with the user consent. +
  3. Initialize Segment using AppsflyerIntegration.FACTORY. +
  4. In the Activity class, use the CMP to decide if you need the consent dialog in the current session. +
  5. If needed, show the consent dialog, using the CMP, to capture the user consent decision. Otherwise, go to step 6. +
  6. Get confirmation from the CMP that the user has made their consent decision, and the data is available in SharedPreferences. +
  7. Call AppsflyerIntegration.startAppsFlyer(this) +
+ + #### Application class +``` kotlin +@Override public void onCreate() { + super.onCreate(); + AppsFlyerLib.getInstance().enableTCFDataCollection(true); + AppsflyerIntegration.setManualMode(true); + initSegmentAnalytics(); +} + +private void initSegmentAnalytics() { + Analytics.Builder builder = new Analytics.Builder(this, SEGMENT_WRITE_KEY) + .use(AppsflyerIntegration.FACTORY) + .logLevel(Analytics.LogLevel.VERBOSE) + .trackApplicationLifecycleEvents() // Enable this to record certain application events automatically! + .recordScreenViews(); // Enable this to record screen views automatically! + // Set the initialized instance as a globally accessible instance. + Analytics.setSingletonInstance(builder.build()); +} +``` +#### Activity class +```kotlin +public class MainActivity extends AppCompatActivity { + + private boolean consentRequired = true; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + if (consentRequired) + initConsentCollection(); + else + AppsflyerIntegration.startAppsFlyer(this); + } + + private void initConsentCollection() { + // Implement here the you CMP flow + // When the flow is completed and consent was collected + // call onConsentCollectionFinished() + } + + private void onConsentCollectionFinished() { + AppsflyerIntegration.startAppsFlyer(this); + } +} +``` + + +### 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. +
    +
  1. Initialize AppsFlyerIntegration using manual mode and also Analytics. This will allow us to delay the Conversion call in order to provide the SDK with the user consent. +
  2. In the Activity class, determine whether the GDPR applies or not to the user.
    + - If GDPR applies to the user, perform the following: +
      +
    1. Given that GDPR is applicable to the user, determine whether the consent data is already stored for this session. +
        +
      1. If there is no consent data stored, show the consent dialog to capture the user consent decision. +
      2. If there is consent data stored continue to the next step. +
      +
    2. To transfer the consent data to the SDK create an object called AppsFlyerConsent using the forGDPRUser() method with the following parameters:
      + - hasConsentForDataUsage - Indicates whether the user has consented to use their data for advertising purposes.
      + - hasConsentForAdsPersonalization - Indicates whether the user has consented to use their data for personalized advertising purposes. +
    3. Call AppsFlyerLib.getInstance().setConsentData() with the AppsFlyerConsent object. +
    4. Call AppsflyerIntegration.startAppsFlyer(this). +

    + - If GDPR doesn’t apply to the user perform the following: +
      +
    1. Create an AppsFlyerConsent object using the forNonGDPRUser() method. This method doesn’t accept any parameters. +
    2. Call AppsFlyerLib.getInstance().setConsentData() with the AppsFlyerConsent object. +
    3. Call AppsflyerIntegration.startAppsFlyer(this). +
    +
+ ###
## Sample App