Reputation: 663
I have a few questions about Google's UserMessagingPlatform
.
Resources
Related questions
.
func requestConsentInfoUpdate(in vc: UIViewController, completion: (() -> Void)?) {
let parameters = UMPRequestParameters()
parameters.tagForUnderAgeOfConsent = false
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
with: parameters,
completionHandler: { [weak self] error in
if error != nil {
// handle error
} else {
if UMPConsentInformation.sharedInstance.formStatus == UMPFormStatus.available {
// if it is avaiable (and required) i load the form
self?.loadForm(in: vc, completion: completion)
} else if UMPConsentInformation.sharedInstance.formStatus == UMPFormStatus.unknown {
// docs suggest to request another update
self?.requestConsentInfoUpdate(in: vc, completion: completion)
} else {
completion?()
}
}
})
}
This function gets called when the first ViewController
is presented, takes as parameters the vc
itself, which will present the form, and a completion
, since I wanna wait for all the privacy stuff before calling GADMobileAds.sharedInstance().start()
and requesting ads.
1. How do I handle the under age flag?
Should I ask the user his age before presenting the form? Or should I just assume that the user is not a minor, like most apps do, and keep tagForUnderAgeOfConsent = false
?
2. Infinite recursion?
By docs, from here:
UMPFormStatusUnknown: Whether a consent form is available is unknown. An update should be requested using requestConsentInfoUpdateWithParameters:completionHandler.
Maybe it's a stupid question, since if the docs advice for it then it should be safe, but could this implementation potentially cause infinite recursion?
private func loadForm(in vc: UIViewController, completion: (() -> Void)?) {
UMPConsentForm.load(completionHandler: { [weak self] form, loadError in
if loadError != nil {
// handle error
} else {
if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.required {
self?.present(form: form, in: vc, completion: completion)
} else {
completion?()
}
}
})
}
private func present(form: UMPConsentForm?, in vc: UIViewController, completion: (() -> Void)?) {
form?.present(
from: vc,
completionHandler: { [weak self] _ in
if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.obtained {
GADMobileAds.sharedInstance().start(completionHandler: nil)
completion?()
}
})
}
Here the form is loaded and presented.
3. Where to pass consensus for mediation partners?
If I understood correctly, UMP pass to its network all the privacy settings under the hood for me once the consensus is obtained. This is just for Google ads, what if I want to use mediation and present also Unity ads, for example? Unity docs explain how, for GDPR consent for example:
let gdprMetaData = UADSMetaData()
gdprMetaData.set("gdpr.consent", value: true)
gdprMetaData.commit()
My question is where should I call this though. From my understanding, UMPConsentStatus.obtained
means just that the the user set his preferences, not necessarily that he agreed to targeted advertising.
Upvotes: 1
Views: 745