3

I'm trying to implement Admob with "Tracking Transparency" and "EU Consent" in Swift.

My app is for iOS 14.0+ devices, so I've followed the instructions on https://developers.google.com/admob/ios/ios14. To be compliant with EU consent for GDPR, I implemented the instructions from https://developers.google.com/admob/ump/ios/quick-start (This is the current implementation for EU consent, not the legacy implementation.).

After that, the dialog "To track users across devices" is shown after the first start of the app. After this, the EU consent dialog will be shown. All works fine.

My question is, is my implementation working so that when Google initializes Admob, it will respect the preferences of the user with tracking transparency and EU consent settings?

Here is my Code:

import SwiftUI
import GoogleMobileAds
import AppTrackingTransparency
import UserMessagingPlatform

@main
struct SampleAdmobWithEuConsent: App {
    
    init() {
        requestIDFA()
    }
    
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
    
    private func initGoogleMobileAds() {
        GADMobileAds.sharedInstance()
            .start(completionHandler: nil)
    }
    
    private func requestIDFA() {
        ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
            // Tracking authorization completed. Start loading ads here.
            showConsentInformation()
        })
    }
    
    private func showConsentInformation() {
        let parameters = UMPRequestParameters()
        
        // false means users are not under age.
        parameters.tagForUnderAgeOfConsent = false
        
        UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
            with: parameters,
            completionHandler: { error in
                if error != nil {
                    // Handle the error.
                } else {
                    // The consent information state was updated.
                    // You are now ready to check if a form is
                    // available.
                    loadForm()
                }
            })
        
    }
    
    func loadForm() {
        UMPConsentForm.load(
            completionHandler: { form, loadError in
                if loadError != nil {
                    // Handle the error
                } else {
                    // Present the form
                    if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.required {
                        form?.present(from: UIApplication.shared.windows.first!.rootViewController! as UIViewController, completionHandler: { dimissError in
                            if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.obtained {
                                // App can start requesting ads.
                                initGoogleMobileAds()
                            }
                        })
                    }
                }
            })
    }
}

I couldn't find a method in GADMobileAds.sharedInstance() to set specified settings, based on the user's preferences from the dialogs. (E.g.: Track me across apps or show me personalized ads).

Thanks in advance!

Ghostw4lk
  • 127
  • 1
  • 11
  • The nice thing about the tracking transparency framework is that it works at the iOS level; if the user denies tracking permission then code that requests the IDFA gets zeros. The ad framework doesn't need to do anything to respect the setting as such; it just won't get an identifier that it could use to track user across apps or show personalised ads – Paulw11 Jan 04 '21 at 21:16
  • Thanks for your answer. You are right, that the second dialog is not necessary if the user selected "Ask app not to track". But it can be possible, that the user selects in the first dialog "Allow tracking" and in the second screen "non personalized apps". Google says that a consent form is always required (https://support.google.com/admob/answer/7676680). So is it necessary to set the selected preferences to the initialization of GADMobileAds or does the framework it internally? – Ghostw4lk Jan 05 '21 at 16:05
  • @Ghostw4lk if the user selects "Allow tracking" in the ATT dialog from iOS, you can show personalized ads. If the user selects "Ask app not to track", then non-personalized ads are shown automatically, as the Ad-ID from the device is hidden/zeroed. So actually, there is no need for a second dialog in iOS 14.5+, or am I wrong? – felix May 07 '21 at 09:36
  • @felix My understanding is you have to show a consent dialog after the ATT dialog for users which are living in the EU/UK. See the second paragraph here https://developers.google.com/admob/ump/ios/quick-start under "Introduction". – Ghostw4lk May 13 '21 at 08:00

1 Answers1

0

I followed your code example and when I test on my simulator, I never get the EU consent dialog. Although I select allow tracking in the first dialog.

Similar Question

El_Loco
  • 1,716
  • 4
  • 20
  • 35