Why is my Google AdMob GDPR consent form not presented in my iOS app

1.2k Views Asked by At

I am in the process of implementing UMP SDK into my iOS app. I have setup the GDPR and IDFA messages in the Google AdMob dashboard's Privacy and Messaging section. I am having trouble getting the GDPR message to show up. The IDFA and iOS' ATT messages work perfectly.

Below is the code that I am using. I have tested this on both simulator and physical device. Also, I am located in the EU.

static func trackingConsentFlow(completion: @escaping () -> Void) {
    let umpParams = UMPRequestParameters()
    let debugSettings = UMPDebugSettings()
    debugSettings.geography = UMPDebugGeography.EEA
    umpParams.debugSettings = debugSettings
    umpParams.tagForUnderAgeOfConsent = false
    
    UMPConsentInformation
        .sharedInstance
        .requestConsentInfoUpdate(with: umpParams,
                                  completionHandler: { error in
            if error != nil {
                print("MYERROR #1 \(String(describing: error))")
                completion()
            } else {
                let formStatus = UMPConsentInformation.sharedInstance.formStatus
                print("FORM STATUS: \(formStatus)")
                
                if formStatus == .available {
                    loadForm(completion)
                } else {
                    completion()
                }
            }
    })
}

private static func loadForm(_ completion: @escaping () -> Void) {
    UMPConsentForm.load(completionHandler: { form, loadError in
        if loadError != nil {
            print("MYERROR #2 \(String(describing: loadError))")
            completion()
        } else {
            print("CONSENT STATUS: \(UMPConsentInformation.sharedInstance.consentStatus)")
            if UMPConsentInformation
                .sharedInstance.consentStatus == .required {
                
                guard let rootViewController = UIApplication.shared.currentUIWindow()?.rootViewController else {
                    return completion()
                }
                
                form?.present(from: rootViewController, completionHandler: { dismissError in
                    if UMPConsentInformation
                        .sharedInstance.consentStatus == .obtained {
                        completion()
                    }
                })
            }
        }
    })
}

Just to be clear:

With this code I am able to show the IDFA message, after which the AppTrackingTransparency alert is shown. But I am expecting to also see the GDPR consent form.

2

There are 2 best solutions below

0
MMise On BEST ANSWER

For anyone wondering the same thing. The GDPR message was not appearing because I had not finalised my Admob account setup. I had not added my payment method. After adding it (and sending the app for review in Admob) the GDPR message started to appear.

0
samkass On

If you're doing initial integration and having trouble getting it to show up at all while XCode debugging, you can enable debug mode by looking in your debug log for the following string:

<UMP SDK> To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[ @"SOME-ID-VALUE" ];

And taking that value and in your Swift code quoted above, setting:

debugSettings.testDeviceIdentifiers = ["SOME-ID-VALUE"]

Given that you already had the IFDA dialog show up, this may not be your specific problem, but for someone else coming here via a Google search the above might be informative.