Reputation: 1866
I am trying to use UserMessagingPlatform
to ask for permission for tracking and the EU GDPR consent. It asks for tracking when running on simulator, but the EU-consent dialog is not showing. What is wrong? I have created both in the Funding Choices in AdMob.
This is on iOS and Swift.
private func requestIDFA() {
if #available(iOS 14, *) {
ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
// Tracking authorization completed. Start loading ads here.
self.showConsentInformation()
})
} else {
// Fallback on earlier versions
}
}
private func showConsentInformation() {
let parameters = UMPRequestParameters()
// false means users are not under age.
parameters.tagForUnderAgeOfConsent = false
let debugSettings = UMPDebugSettings()
debugSettings.geography = UMPDebugGeography.EEA
parameters.debugSettings = debugSettings
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.
let formStatus = UMPConsentInformation.sharedInstance.formStatus
if formStatus == UMPFormStatus.available {
self.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()
}
})
}
}
})
}
Upvotes: 2
Views: 1623
Reputation: 61
I think AdMob might have treated emulators as a special case. This is what Google says:
Emulators do not need to be added to the device id list as they have testing enabled by default.
Perhaps it makes sense to try to tweak it with the debug code explained here under section Force a geography
I'm running into another odd issue: my test iPhone located outside of EU is being shown the GDPR form consistently on initial run on fresh installs because somehow the UMP keeps returning consentStatus as "required". I expect it to return "notRequired" but it's not happening. It seems like AdMob is not doing it job detecting whether or not my iPhone is in EU or not.
Upvotes: 1