From 848986d73e44df641f2ab2718928a7592b8436d9 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 25 Jul 2023 12:28:01 +0200 Subject: [PATCH] feat: google ump sdk upgrade - 2.1.0 --- ...actNativeGoogleMobileAdsConsentModule.java | 18 ++++++++++ .../RNGoogleMobileAdsConsentModule.m | 21 +++++++++++ package.json | 4 +-- ...sConsentPrivacyOptionsRequirementStatus.ts | 36 +++++++++++++++++++ src/types/AdsConsent.interface.ts | 11 ++++++ 5 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/AdsConsentPrivacyOptionsRequirementStatus.ts diff --git a/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java b/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java index 9c3d1a85..158ac599 100644 --- a/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +++ b/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java @@ -56,6 +56,19 @@ private String getConsentStatusString(int consentStatus) { } } + private String getPrivacyOptionsRequirementStatusString( + ConsentInformation.PrivacyOptionsRequirementStatus privacyOptionsRequirementStatus) { + switch (privacyOptionsRequirementStatus) { + case REQUIRED: + return "REQUIRED"; + case NOT_REQUIRED: + return "NOT_REQUIRED"; + case UNKNOWN: + default: + return "UNKNOWN"; + } + } + @ReactMethod public void requestInfoUpdate(@Nonnull final ReadableMap options, final Promise promise) { try { @@ -98,6 +111,11 @@ public void requestInfoUpdate(@Nonnull final ReadableMap options, final Promise WritableMap requestInfoMap = Arguments.createMap(); requestInfoMap.putString( "status", getConsentStatusString(consentInformation.getConsentStatus())); + requestInfoMap.putBoolean("canRequestAds", consentInformation.canRequestAds()); + requestInfoMap.putString( + "privacyOptionsRequirementStatus", + getPrivacyOptionsRequirementStatusString( + consentInformation.getPrivacyOptionsRequirementStatus())); requestInfoMap.putBoolean( "isConsentFormAvailable", consentInformation.isConsentFormAvailable()); promise.resolve(requestInfoMap); diff --git a/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m b/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m index 80288a85..02ec5bff 100644 --- a/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +++ b/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m @@ -55,6 +55,21 @@ - (NSString *)getConsentStatusString:(UMPConsentStatus)consentStatus { } #endif +#if !TARGET_OS_MACCATALYST +- (NSString *)getPrivacyOptionsRequirementStatusString: + (UMPPrivacyOptionsRequirementStatus)privacyOptionsRequirementStatus { + switch (privacyOptionsRequirementStatus) { + case UMPPrivacyOptionsRequirementStatusRequired: + return @"REQUIRED"; + case UMPPrivacyOptionsRequirementStatusNotRequired: + return @"NOT_REQUIRED"; + case UMPPrivacyOptionsRequirementStatusUnknown: + default: + return @"UNKNOWN"; + } +} +#endif + RCT_EXPORT_METHOD(requestInfoUpdate : (NSDictionary *)options : (RCTPromiseResolveBlock)resolve @@ -85,6 +100,12 @@ - (NSString *)getConsentStatusString:(UMPConsentStatus)consentStatus { @"status" : [self getConsentStatusString:UMPConsentInformation.sharedInstance .consentStatus], + @"canRequestAds" : + @(UMPConsentInformation.sharedInstance.canRequestAds), + @"privacyOptionsRequirementStatus" : + [self getPrivacyOptionsRequirementStatusString: + UMPConsentInformation.sharedInstance + .privacyOptionsRequirementStatus], @"isConsentFormAvailable" : @(UMPConsentInformation.sharedInstance.formStatus == UMPFormStatusAvailable) diff --git a/package.json b/package.json index ff637b77..a2272326 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "sdkVersions": { "ios": { "googleMobileAds": "10.8.0", - "googleUmp": "2.0.1" + "googleUmp": "2.1.0" }, "android": { "minSdk": 19, @@ -50,7 +50,7 @@ "compileSdk": 31, "buildTools": "31.0.0", "googleMobileAds": "22.2.0", - "googleUmp": "2.0.0" + "googleUmp": "2.1.0" } }, "react-native-builder-bob": { diff --git a/src/AdsConsentPrivacyOptionsRequirementStatus.ts b/src/AdsConsentPrivacyOptionsRequirementStatus.ts new file mode 100644 index 00000000..98e75211 --- /dev/null +++ b/src/AdsConsentPrivacyOptionsRequirementStatus.ts @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016-present Invertase Limited & Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this library except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * AdsConsentPrivacyOptionsRequirementStatus enum. + */ +export enum AdsConsentPrivacyOptionsRequirementStatus { + /** + * Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it. + */ + UNKNOWN = 'UNKNOWN', + + /** + * User consent required but not yet obtained. + */ + REQUIRED = 'REQUIRED', + + /** + * User consent not required. + */ + NOT_REQUIRED = 'NOT_REQUIRED', +} diff --git a/src/types/AdsConsent.interface.ts b/src/types/AdsConsent.interface.ts index 1f458552..72c4661d 100644 --- a/src/types/AdsConsent.interface.ts +++ b/src/types/AdsConsent.interface.ts @@ -1,6 +1,7 @@ import { TCModel } from '@iabtcf/core'; import { AdsConsentDebugGeography } from '../AdsConsentDebugGeography'; import { AdsConsentStatus } from '../AdsConsentStatus'; +import { AdsConsentPrivacyOptionsRequirementStatus } from '../AdsConsentPrivacyOptionsRequirementStatus'; /** * Under the Google [EU User Consent Policy](https://www.google.com/about/company/consentstaging.html), you must make certain disclosures to your users in the European Economic Area (EEA) @@ -167,6 +168,16 @@ export interface AdsConsentInfo { */ status: AdsConsentStatus; + /** + * Indicates whether the app has completed the necessary steps for gathering updated user consent. + */ + canRequestAds: boolean; + + /** + * Privacy options requirement status. + */ + privacyOptionsRequirementStatus: AdsConsentPrivacyOptionsRequirementStatus; + /** * If `true` a consent form is available. */