Google replaced their Consent SDK with the User Messaging Platform (UMP) SDK, which supports the latest IAB standards and Apple's App Tracking Transparency requirements.
Please refer to the following links for more information:
Previously it was possible to request the ad providers and to update the consent status. This is no longer the case.
Also, while the old Consent SDK provided information about user preferences, the new AdsConsentStatus
only tells you if you should show the modal to a user or not.
requestInfoUpdate
does now accept an optionalAdsConsentInfoOptions
object instead of expectingpublisherIds
and returns a changedAdsConsentInfo
interfaceshowForm
does not expect any parameters any longer and now only returns the changedAdsConsentStatus
as part of it'sAdsConsentFormResult
interfacegetAdProviders
,getStatus
andsetStatus
methods were removed without replacementsaddTestDevices
,setDebugGeography
andsetTagForUnderAgeOfConsent
methods were removed, but their functionality is available viaAdsConsentInfoOptions
- the
user_tracking_usage_description
key is needed in your project'sapp.json
if you want to handle Apple's App Tracking Transparency - newly added
getUserChoices
can be used to inspect some of the consent choices
{
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
+ "user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you."
}
}
import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
-const consentInfo = await AdsConsent.requestInfoUpdate(['pub-6189033257628123']);
+const consentInfo = await AdsConsent.requestInfoUpdate();
if (
- consentInfo.isRequestLocationInEeaOrUnknown &&
+ consentInfo.isConsentFormAvailable &&
- consentInfo.status === AdsConsentStatus.UNKNOWN
+ consentInfo.status === AdsConsentStatus.REQUIRED
) {
- const formResult = await AdsConsent.showForm({
- privacyPolicy: 'https://invertase.io/privacy-policy',
- withPersonalizedAds: true,
- withNonPersonalizedAds: true,
- withAdFree: true,
- });
+ const formResult = await AdsConsent.showForm()
+
+ const { storeAndAccessInformationOnDevice } = await AdsConsent.getUserChoices();
+
+ if (storeAndAccessInformationOnDevice === false) {
+ /**
+ * The user declined consent for purpose 1,
+ * the Google Mobile Ads SDK won't serve ads.
+ */
+ }
}