Skip to content

Commit

Permalink
feat: google ump sdk upgrade - 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dylancom committed Jul 25, 2023
1 parent 57ec80c commit 848986d
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
"sdkVersions": {
"ios": {
"googleMobileAds": "10.8.0",
"googleUmp": "2.0.1"
"googleUmp": "2.1.0"
},
"android": {
"minSdk": 19,
"targetSdk": 30,
"compileSdk": 31,
"buildTools": "31.0.0",
"googleMobileAds": "22.2.0",
"googleUmp": "2.0.0"
"googleUmp": "2.1.0"
}
},
"react-native-builder-bob": {
Expand Down
36 changes: 36 additions & 0 deletions src/AdsConsentPrivacyOptionsRequirementStatus.ts
Original file line number Diff line number Diff line change
@@ -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',
}
11 changes: 11 additions & 0 deletions src/types/AdsConsent.interface.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 848986d

Please sign in to comment.