We’ve Made Updates to the Person Messaging Platform SDK APIs
In case you missed it, we introduced new consent administration platform necessities for serving adverts within the EEA and UK. Starting January 16, 2024, Google would require all publishers to make use of a Google-certified consent administration platform (CMP) when serving adverts to customers within the European Financial Space or the UK.
Along with rising our checklist of licensed CMPs, we explored tips on how to enhance the Person Messaging Platform (UMP) SDK developer expertise for individuals who select to make use of Google’s consent administration resolution. We’re excited to share a number of updates within the newest iOS and Android variations that we predict will streamline your integration.
Loading and presenting a consent type
The newest UMP SDK launch introduces a brand new API, loadAndPresentIfRequired(), that consolidates the present particular person load and current consent type strategies right into a single technique. The brand new API hundreds a consent type and if consent is required, mechanically presents the consent type. This technique is meant for use originally of a brand new app session.
Here’s a code instance of tips on how to use the brand new API on iOS:
class ViewController: UIViewController {
non-public var isMobileAdsStartCalled = false
override func viewDidLoad() {
tremendous.viewDidLoad()
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: parameters) {
[weak self] requestConsentError in
guard let self else { return }
// Name the helper technique as soon as consent data has been up to date.
UMPConsentForm.loadAndPresentIfRequired(from: self) {
[weak self] loadAndPresentError in
guard let self else { return }
if UMPConsentInformation.sharedInstance.canRequestAds {
self.startGoogleMobileAdsSDK()
}
}
}
// canRequestAds will likely be true if consent was gathered within the earlier session.
if UMPConsentInformation.sharedInstance.canRequestAds {
startGoogleMobileAdsSDK()
}
}
non-public func startGoogleMobileAdsSDK() {
DispatchQueue.fundamental.async {
guard !self.isMobileAdsStartCalled else { return }
self.isMobileAdsStartCalled = true
// Initialize the Google Cell Adverts SDK.
GADMobileAds.sharedInstance().begin()
// Request an advert.
GADInterstitialAd.load(...)
}
}
}
Checking when to request adverts
We added a brand new boolean property canRequestAds to make use of as a examine earlier than initializing the Google Cell Adverts SDK and requesting adverts. canRequestAds returns true when the consent standing is both OBTAINED or NOT_REQUIRED; consequently you don’t have to implement any enum checking your self.
You must use the canRequestAds API in two locations (as seen within the code snippet above):
- As soon as consent has been gathered within the present session.
- Instantly after you might have known as
requestConsentInfoUpdate.It’s doable consent has been gathered within the earlier session during which case it’s not essential to attend for the callback to complete.
Checking privateness choices requirement standing
GDPR requires that publishers permit customers to withdraw their consent decisions at any time. It must be as straightforward to withdraw consent as it’s to assemble consent. To simplify this course of, we now have added two new APIs:
- privacyOptionsRequirementStatus to find out whether or not it is best to embody a UI component that may re-present the consent type, comparable to a button in your utility’s settings web page.
- presentPrivacyOptionsForm() to point out the shape so the person can replace their consent standing at any time.
Here’s a code instance of tips on how to use the brand new APIs on iOS:
// Present a privateness choices button if required.
non-public var isPrivacySettingsButtonEnabled: Bool {
return UMPConsentInformation.shared.privacyOptionsRequirementStatus == .required
}
// Current the privateness choices type when a person interacts along with your app.
@IBAction func privacySettingsTapped(_ sender: UIBarButtonItem) {
UMPConsentForm.presentPrivacyOptionsForm(from: self) {
[weak self] formError in
guard let self, let formError else { return }
// Deal with the error.
}
}
Developer sources
We up to date our AdMob banner samples functions for iOS and Android to showcase integrating the UMP SDK. Maintain a watch out as we add UMP SDK help to the remainder of our samples quickly.
Additionally check out our iOS and Android developer documentation for directions on tips on how to implement the UMP SDK.
If in case you have any questions or want further assist integrating the UMP SDK, please contact us through the developer discussion board.