Migrating to v5
AdsConsent
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.
requestInfoUpdatedoes now accept an optionalAdsConsentInfoOptionsobject instead of expectingpublisherIdsand returns a changedAdsConsentInfointerfaceshowFormdoes not expect any parameters any longer and now only returns the changedAdsConsentStatusas part of it'sAdsConsentFormResultinterfacegetAdProviders,getStatusandsetStatusmethods were removed without replacementsaddTestDevices,setDebugGeographyandsetTagForUnderAgeOfConsentmethods were removed, but their functionality is available viaAdsConsentInfoOptions- the
user_tracking_usage_descriptionkey is needed in your project'sapp.jsonif you want to handle Apple's App Tracking Transparency - newly added
getUserChoicescan 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.
+ */
+ }
}