react-native-google-mobile-ads 4.1.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNGoogleMobileAds.podspec +16 -9
- package/__tests__/consent.test.ts +17 -9
- package/android/build.gradle +4 -3
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsAppOpenModule.java +2 -5
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsCommon.java +13 -2
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +100 -171
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsInterstitialModule.java +6 -5
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsRewardedModule.java +3 -4
- package/docs/common-reasons-for-ads-not-showing.mdx +92 -0
- package/docs/european-user-consent.mdx +43 -161
- package/docs/index.mdx +3 -3
- package/docs/migrating-to-v5.mdx +54 -0
- package/docs.json +3 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsAppOpenModule.m +1 -2
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.h +1 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsCommon.m +6 -2
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +0 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +71 -126
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsInterstitialModule.m +1 -2
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsRewardedModule.m +1 -2
- package/ios_config.sh +8 -0
- package/lib/commonjs/AdsConsent.js +29 -100
- package/lib/commonjs/AdsConsent.js.map +1 -1
- package/lib/commonjs/AdsConsentStatus.js +4 -3
- package/lib/commonjs/AdsConsentStatus.js.map +1 -1
- package/lib/commonjs/validateAdRequestOptions.js +8 -0
- package/lib/commonjs/validateAdRequestOptions.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/AdsConsent.js +30 -100
- package/lib/module/AdsConsent.js.map +1 -1
- package/lib/module/AdsConsentStatus.js +4 -3
- package/lib/module/AdsConsentStatus.js.map +1 -1
- package/lib/module/validateAdRequestOptions.js +8 -0
- package/lib/module/validateAdRequestOptions.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/AdsConsentStatus.d.ts +10 -6
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/types/AdsConsent.interface.d.ts +37 -204
- package/lib/typescript/types/RequestOptions.d.ts +8 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +5 -3
- package/src/AdsConsent.ts +36 -135
- package/src/AdsConsentStatus.ts +11 -6
- package/src/types/AdsConsent.interface.ts +37 -214
- package/src/types/RequestOptions.ts +7 -0
- package/src/validateAdRequestOptions.ts +7 -0
- package/src/version.ts +1 -1
|
@@ -68,9 +68,8 @@ RCT_EXPORT_METHOD(rewardedLoad
|
|
|
68
68
|
: (nonnull NSNumber *)requestId
|
|
69
69
|
: (NSString *)adUnitId
|
|
70
70
|
: (NSDictionary *)adRequestOptions) {
|
|
71
|
-
GADRequest *request = [GADRequest request];
|
|
72
71
|
[GADRewardedAd loadWithAdUnitID:adUnitId
|
|
73
|
-
request:
|
|
72
|
+
request:[RNGoogleMobileAdsCommon buildAdRequest:adRequestOptions]
|
|
74
73
|
completionHandler:^(GADRewardedAd *ad, NSError *error) {
|
|
75
74
|
if (error) {
|
|
76
75
|
NSDictionary *codeAndMessage =
|
package/ios_config.sh
CHANGED
|
@@ -102,6 +102,14 @@ if [[ ${_SEARCH_RESULT} ]]; then
|
|
|
102
102
|
_PLIST_ENTRY_TYPES+=("string")
|
|
103
103
|
_PLIST_ENTRY_VALUES+=("$_IOS_APP_ID")
|
|
104
104
|
fi
|
|
105
|
+
|
|
106
|
+
# config.user_tracking_usage_description
|
|
107
|
+
_USER_TRACKING_USAGE_DESCRIPTION=$(getJsonKeyValue "$_JSON_OUTPUT_RAW" "user_tracking_usage_description")
|
|
108
|
+
if [[ $_USER_TRACKING_USAGE_DESCRIPTION ]]; then
|
|
109
|
+
_PLIST_ENTRY_KEYS+=("NSUserTrackingUsageDescription")
|
|
110
|
+
_PLIST_ENTRY_TYPES+=("string")
|
|
111
|
+
_PLIST_ENTRY_VALUES+=("$_USER_TRACKING_USAGE_DESCRIPTION")
|
|
112
|
+
fi
|
|
105
113
|
else
|
|
106
114
|
_PLIST_ENTRY_KEYS+=("google_mobile_ads_json_raw")
|
|
107
115
|
_PLIST_ENTRY_TYPES+=("string")
|
|
@@ -11,8 +11,6 @@ var _reactNative = require("react-native");
|
|
|
11
11
|
|
|
12
12
|
var _AdsConsentDebugGeography = require("./AdsConsentDebugGeography");
|
|
13
13
|
|
|
14
|
-
var _AdsConsentStatus = require("./AdsConsentStatus");
|
|
15
|
-
|
|
16
14
|
/*
|
|
17
15
|
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
18
16
|
*
|
|
@@ -33,126 +31,57 @@ const native = _reactNative.NativeModules.RNGoogleMobileAdsConsentModule;
|
|
|
33
31
|
const AdsConsent = {
|
|
34
32
|
/**
|
|
35
33
|
*
|
|
36
|
-
* @param
|
|
37
|
-
* @
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (publisherIds.length === 0) {
|
|
45
|
-
throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
for (let i = 0; i < publisherIds.length; i++) {
|
|
49
|
-
if (!(0, _common.isString)(publisherIds[i])) {
|
|
50
|
-
throw new Error(`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return native.requestInfoUpdate(publisherIds);
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @param options
|
|
60
|
-
* @returns {*}
|
|
34
|
+
* @param {Object} [options]
|
|
35
|
+
* @param {AdsConsentDebugGeography} [options.debugGeography]
|
|
36
|
+
* @param {Boolean} [options.tagForUnderAgeOfConsent]
|
|
37
|
+
* @param {Array<String>} [options.testDeviceIdentifiers]
|
|
38
|
+
* @returns {{ status: Number, isConsentFormAvailable: Boolean }}
|
|
61
39
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
throw new Error("AdsConsent.showForm(*) 'options' expected an object value.");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!(0, _common.isValidUrl)(options.privacyPolicy)) {
|
|
68
|
-
throw new Error("AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if ((0, _common.hasOwnProperty)(options, 'withPersonalizedAds') && !(0, _common.isBoolean)(options.withPersonalizedAds)) {
|
|
72
|
-
throw new Error("AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.");
|
|
73
|
-
}
|
|
40
|
+
requestInfoUpdate() {
|
|
41
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
74
42
|
|
|
75
|
-
if (
|
|
76
|
-
throw new Error("AdsConsent.
|
|
43
|
+
if (!(0, _common.isObject)(options)) {
|
|
44
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value.");
|
|
77
45
|
}
|
|
78
46
|
|
|
79
|
-
if ((0, _common.hasOwnProperty)(options, '
|
|
80
|
-
throw new Error("AdsConsent.
|
|
47
|
+
if ((0, _common.hasOwnProperty)(options, 'debugGeography') && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.DISABLED && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.EEA && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.NOT_EEA) {
|
|
48
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.");
|
|
81
49
|
}
|
|
82
50
|
|
|
83
|
-
if (
|
|
84
|
-
throw new Error("AdsConsent.
|
|
51
|
+
if ((0, _common.hasOwnProperty)(options, 'tagForUnderAgeOfConsent') && !(0, _common.isBoolean)(options.tagForUnderAgeOfConsent)) {
|
|
52
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.");
|
|
85
53
|
}
|
|
86
54
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
getAdProviders() {
|
|
94
|
-
return native.getAdProviders();
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* @param geography
|
|
100
|
-
*/
|
|
101
|
-
setDebugGeography(geography) {
|
|
102
|
-
if (geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.DISABLED && geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.EEA && geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.NOT_EEA) {
|
|
103
|
-
throw new Error("AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.");
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return native.setDebugGeography(geography);
|
|
107
|
-
},
|
|
55
|
+
if ((0, _common.hasOwnProperty)(options, 'testDeviceIdentifiers')) {
|
|
56
|
+
if (!(0, _common.isArray)(options.testDeviceIdentifiers)) {
|
|
57
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.");
|
|
58
|
+
}
|
|
108
59
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*/
|
|
112
|
-
getStatus() {
|
|
113
|
-
return native.getStatus();
|
|
114
|
-
},
|
|
60
|
+
for (const deviceId of (_options$testDeviceId = options.testDeviceIdentifiers) !== null && _options$testDeviceId !== void 0 ? _options$testDeviceId : []) {
|
|
61
|
+
var _options$testDeviceId;
|
|
115
62
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
setStatus(status) {
|
|
121
|
-
if (status !== _AdsConsentStatus.AdsConsentStatus.UNKNOWN && status !== _AdsConsentStatus.AdsConsentStatus.NON_PERSONALIZED && status !== _AdsConsentStatus.AdsConsentStatus.PERSONALIZED) {
|
|
122
|
-
throw new Error("AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED.");
|
|
63
|
+
if (!(0, _common.isString)(deviceId)) {
|
|
64
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
123
67
|
}
|
|
124
68
|
|
|
125
|
-
return native.
|
|
69
|
+
return native.requestInfoUpdate(options);
|
|
126
70
|
},
|
|
127
71
|
|
|
128
72
|
/**
|
|
129
73
|
*
|
|
130
|
-
* @
|
|
74
|
+
* @returns {{ status: Number }}
|
|
131
75
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value.");
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return native.setTagForUnderAgeOfConsent(tag);
|
|
76
|
+
showForm() {
|
|
77
|
+
return native.showForm();
|
|
138
78
|
},
|
|
139
79
|
|
|
140
80
|
/**
|
|
141
81
|
*
|
|
142
|
-
* @param deviceIds
|
|
143
82
|
*/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.");
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
for (let i = 0; i < deviceIds.length; i++) {
|
|
150
|
-
if (!(0, _common.isString)(deviceIds[i])) {
|
|
151
|
-
throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.");
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return native.addTestDevices(deviceIds);
|
|
83
|
+
reset() {
|
|
84
|
+
return native.reset();
|
|
156
85
|
}
|
|
157
86
|
|
|
158
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["AdsConsent.ts"],"names":["native","NativeModules","RNGoogleMobileAdsConsentModule","AdsConsent","requestInfoUpdate","
|
|
1
|
+
{"version":3,"sources":["AdsConsent.ts"],"names":["native","NativeModules","RNGoogleMobileAdsConsentModule","AdsConsent","requestInfoUpdate","options","Error","debugGeography","AdsConsentDebugGeography","DISABLED","EEA","NOT_EEA","tagForUnderAgeOfConsent","testDeviceIdentifiers","deviceId","showForm","reset"],"mappings":";;;;;;;AAiBA;;AACA;;AACA;;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA,MAAMA,MAAM,GAAGC,2BAAcC,8BAA7B;AAEO,MAAMC,UAA+B,GAAG;AAC7C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,iBAAiB,GAAe;AAAA,QAAdC,OAAc,uEAAJ,EAAI;;AAC9B,QAAI,CAAC,sBAASA,OAAT,CAAL,EAAwB;AACtB,YAAM,IAAIC,KAAJ,CAAU,qEAAV,CAAN;AACD;;AAED,QACE,4BAAeD,OAAf,EAAwB,gBAAxB,KACAA,OAAO,CAACE,cAAR,KAA2BC,mDAAyBC,QADpD,IAEAJ,OAAO,CAACE,cAAR,KAA2BC,mDAAyBE,GAFpD,IAGAL,OAAO,CAACE,cAAR,KAA2BC,mDAAyBG,OAJtD,EAKE;AACA,YAAM,IAAIL,KAAJ,CACJ,+KADI,CAAN;AAGD;;AAED,QACE,4BAAeD,OAAf,EAAwB,yBAAxB,KACA,CAAC,uBAAUA,OAAO,CAACO,uBAAlB,CAFH,EAGE;AACA,YAAM,IAAIN,KAAJ,CACJ,6FADI,CAAN;AAGD;;AAED,QAAI,4BAAeD,OAAf,EAAwB,uBAAxB,CAAJ,EAAsD;AACpD,UAAI,CAAC,qBAAQA,OAAO,CAACQ,qBAAhB,CAAL,EAA6C;AAC3C,cAAM,IAAIP,KAAJ,CACJ,qGADI,CAAN;AAGD;;AAED,WAAK,MAAMQ,QAAX,6BAAuBT,OAAO,CAACQ,qBAA/B,yEAAwD,EAAxD,EAA4D;AAAA;;AAC1D,YAAI,CAAC,sBAASC,QAAT,CAAL,EAAyB;AACvB,gBAAM,IAAIR,KAAJ,CACJ,qGADI,CAAN;AAGD;AACF;AACF;;AAED,WAAON,MAAM,CAACI,iBAAP,CAAyBC,OAAzB,CAAP;AACD,GAnD4C;;AAqD7C;AACF;AACA;AACA;AACEU,EAAAA,QAAQ,GAAG;AACT,WAAOf,MAAM,CAACe,QAAP,EAAP;AACD,GA3D4C;;AA6D7C;AACF;AACA;AACEC,EAAAA,KAAK,GAAG;AACN,WAAOhB,MAAM,CAACgB,KAAP,EAAP;AACD;;AAlE4C,CAAxC","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { hasOwnProperty, isArray, isBoolean, isObject, isString } from './common';\nimport { NativeModules } from 'react-native';\nimport { AdsConsentDebugGeography } from './AdsConsentDebugGeography';\nimport { AdsConsentInterface } from './types/AdsConsent.interface';\n\nconst native = NativeModules.RNGoogleMobileAdsConsentModule;\n\nexport const AdsConsent: AdsConsentInterface = {\n /**\n *\n * @param {Object} [options]\n * @param {AdsConsentDebugGeography} [options.debugGeography]\n * @param {Boolean} [options.tagForUnderAgeOfConsent]\n * @param {Array<String>} [options.testDeviceIdentifiers]\n * @returns {{ status: Number, isConsentFormAvailable: Boolean }}\n */\n requestInfoUpdate(options = {}) {\n if (!isObject(options)) {\n throw new Error(\"AdsConsent.requestInfoUpdate(*) 'options' expected an object value.\");\n }\n\n if (\n hasOwnProperty(options, 'debugGeography') &&\n options.debugGeography !== AdsConsentDebugGeography.DISABLED &&\n options.debugGeography !== AdsConsentDebugGeography.EEA &&\n options.debugGeography !== AdsConsentDebugGeography.NOT_EEA\n ) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.\",\n );\n }\n\n if (\n hasOwnProperty(options, 'tagForUnderAgeOfConsent') &&\n !isBoolean(options.tagForUnderAgeOfConsent)\n ) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.\",\n );\n }\n\n if (hasOwnProperty(options, 'testDeviceIdentifiers')) {\n if (!isArray(options.testDeviceIdentifiers)) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.\",\n );\n }\n\n for (const deviceId of options.testDeviceIdentifiers ?? []) {\n if (!isString(deviceId)) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.\",\n );\n }\n }\n }\n\n return native.requestInfoUpdate(options);\n },\n\n /**\n *\n * @returns {{ status: Number }}\n */\n showForm() {\n return native.showForm();\n },\n\n /**\n *\n */\n reset() {\n return native.reset();\n },\n};\n"]}
|
|
@@ -29,8 +29,9 @@ let AdsConsentStatus;
|
|
|
29
29
|
exports.AdsConsentStatus = AdsConsentStatus;
|
|
30
30
|
|
|
31
31
|
(function (AdsConsentStatus) {
|
|
32
|
-
AdsConsentStatus[
|
|
33
|
-
AdsConsentStatus[
|
|
34
|
-
AdsConsentStatus[
|
|
32
|
+
AdsConsentStatus["UNKNOWN"] = "UNKNOWN";
|
|
33
|
+
AdsConsentStatus["REQUIRED"] = "REQUIRED";
|
|
34
|
+
AdsConsentStatus["NOT_REQUIRED"] = "NOT_REQUIRED";
|
|
35
|
+
AdsConsentStatus["OBTAINED"] = "OBTAINED";
|
|
35
36
|
})(AdsConsentStatus || (exports.AdsConsentStatus = AdsConsentStatus = {}));
|
|
36
37
|
//# sourceMappingURL=AdsConsentStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["AdsConsentStatus.ts"],"names":["AdsConsentStatus"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;IACYA,gB;;;WAAAA,gB;AAAAA,EAAAA,gB,
|
|
1
|
+
{"version":3,"sources":["AdsConsentStatus.ts"],"names":["AdsConsentStatus"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;IACYA,gB;;;WAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,gCAAAA,gB","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\n/**\n * AdsConsentStatus enum.\n */\nexport enum AdsConsentStatus {\n /**\n * Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it.\n */\n UNKNOWN = 'UNKNOWN',\n\n /**\n * User consent required but not yet obtained.\n */\n REQUIRED = 'REQUIRED',\n\n /**\n * User consent not required.\n */\n NOT_REQUIRED = 'NOT_REQUIRED',\n\n /**\n * User consent already obtained.\n */\n OBTAINED = 'OBTAINED',\n}\n"]}
|
|
@@ -153,6 +153,14 @@ function validateAdRequestOptions(options) {
|
|
|
153
153
|
out.serverSideVerificationOptions = options.serverSideVerificationOptions;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
if (options.customTargeting) {
|
|
157
|
+
if (!(0, _common.isObject)(options.customTargeting)) {
|
|
158
|
+
throw new Error("'options.customTargeting' expected an object of key/value pairs");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
out.customTargeting = options.customTargeting;
|
|
162
|
+
}
|
|
163
|
+
|
|
156
164
|
return out;
|
|
157
165
|
}
|
|
158
166
|
//# sourceMappingURL=validateAdRequestOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["validateAdRequestOptions.ts"],"names":["validateAdRequestOptions","options","out","Error","requestNonPersonalizedAdsOnly","networkExtras","Object","entries","forEach","key","value","keywords","i","length","keyword","contentUrl","location","error","latitude","longitude","locationAccuracy","requestAgent","serverSideVerificationOptions","ssvOptions","userId","customData"],"mappings":";;;;;;;AAiBA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,SAASA,wBAAT,CAAkCC,OAAlC,EAA4D;AACjE,QAAMC,GAAmB,GAAG,EAA5B;;AAEA,MAA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A,GAAG,CAACoB,6BAAJ,GAAoCrB,OAAO,CAACqB,6BAA5C;AACD;;AAED,
|
|
1
|
+
{"version":3,"sources":["validateAdRequestOptions.ts"],"names":["validateAdRequestOptions","options","out","Error","requestNonPersonalizedAdsOnly","networkExtras","Object","entries","forEach","key","value","keywords","i","length","keyword","contentUrl","location","error","latitude","longitude","locationAccuracy","requestAgent","serverSideVerificationOptions","ssvOptions","userId","customData","customTargeting"],"mappings":";;;;;;;AAiBA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,SAASA,wBAAT,CAAkCC,OAAlC,EAA4D;AACjE,QAAMC,GAAmB,GAAG,EAA5B;;AAEA,MAAI,yBAAYD,OAAZ,CAAJ,EAA0B;AACxB,WAAOC,GAAP;AACD;;AAED,MAAI,CAAC,sBAASD,OAAT,CAAL,EAAwB;AACtB,UAAM,IAAIE,KAAJ,CAAU,oCAAV,CAAN;AACD;;AAED,MAAI,4BAAeF,OAAf,EAAwB,+BAAxB,CAAJ,EAA8D;AAC5D,QAAI,CAAC,uBAAUA,OAAO,CAACG,6BAAlB,CAAL,EAAuD;AACrD,YAAM,IAAID,KAAJ,CAAU,kEAAV,CAAN;AACD;;AAEDD,IAAAA,GAAG,CAACE,6BAAJ,GAAoCH,OAAO,CAACG,6BAA5C;AACD;;AAED,MAAIH,OAAO,CAACI,aAAZ,EAA2B;AACzB,QAAI,CAAC,sBAASJ,OAAO,CAACI,aAAjB,CAAL,EAAsC;AACpC,YAAM,IAAIF,KAAJ,CAAU,+DAAV,CAAN;AACD;;AAEDG,IAAAA,MAAM,CAACC,OAAP,CAAeN,OAAO,CAACI,aAAvB,EAAsCG,OAAtC,CAA8C,QAAkB;AAAA,UAAjB,CAACC,GAAD,EAAMC,KAAN,CAAiB;;AAC9D,UAAI,CAAC,sBAASA,KAAT,CAAL,EAAsB;AACpB,cAAM,IAAIP,KAAJ,CAAW,mEAAkEM,GAAI,G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AZ,EAA2C;AACzC,QAAI,CAAC,sBAASrB,OAAO,CAACqB,6BAAjB,CAAL,EAAsD;AACpD,YAAM,IAAInB,KAAJ,CACJ,+EADI,CAAN;AAGD;;AAED,UAAMoB,UAAU,GAAGtB,OAAO,CAACqB,6BAA3B;;AAEA,QAAIC,UAAU,CAACC,MAAX,IAAqB,CAAC,sBAASD,UAAU,CAACC,MAApB,CAA1B,EAAuD;AACrD,YAAM,IAAIrB,KAAJ,CAAU,wEAAV,CAAN;AACD;;AAED,QAAIoB,UAAU,CAACE,UAAX,IAAyB,CAAC,sBAASF,UAAU,CAACE,UAApB,CAA9B,EAA+D;AAC7D,YAAM,IAAItB,KAAJ,CAAU,4EAAV,CAAN;AACD;;AAEDD,IAAAA,GAAG,CAACoB,6BAAJ,GAAoCrB,OAAO,CAACqB,6BAA5C;AACD;;AAED,MAAIrB,OAAO,CAACyB,eAAZ,EAA6B;AAC3B,QAAI,CAAC,sBAASzB,OAAO,CAACyB,eAAjB,CAAL,EAAwC;AACtC,YAAM,IAAIvB,KAAJ,CAAU,iEAAV,CAAN;AACD;;AACDD,IAAAA,GAAG,CAACwB,eAAJ,GAAsBzB,OAAO,CAACyB,eAA9B;AACD;;AAED,SAAOxB,GAAP;AACD","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport {\n hasOwnProperty,\n isArray,\n isBoolean,\n isNumber,\n isObject,\n isString,\n isUndefined,\n isValidUrl,\n} from './common';\nimport { RequestOptions } from './types/RequestOptions';\n\nexport function validateAdRequestOptions(options?: RequestOptions) {\n const out: RequestOptions = {};\n\n if (isUndefined(options)) {\n return out;\n }\n\n if (!isObject(options)) {\n throw new Error(\"'options' expected an object value\");\n }\n\n if (hasOwnProperty(options, 'requestNonPersonalizedAdsOnly')) {\n if (!isBoolean(options.requestNonPersonalizedAdsOnly)) {\n throw new Error(\"'options.requestNonPersonalizedAdsOnly' expected a boolean value\");\n }\n\n out.requestNonPersonalizedAdsOnly = options.requestNonPersonalizedAdsOnly;\n }\n\n if (options.networkExtras) {\n if (!isObject(options.networkExtras)) {\n throw new Error(\"'options.networkExtras' expected an object of key/value pairs\");\n }\n\n Object.entries(options.networkExtras).forEach(([key, value]) => {\n if (!isString(value)) {\n throw new Error(`'options.networkExtras' expected a string value for object key \"${key}\"`);\n }\n });\n\n out.networkExtras = options.networkExtras;\n }\n\n if (options.keywords) {\n if (!isArray(options.keywords)) {\n throw new Error(\"'options.keywords' expected an array containing string values\");\n }\n\n for (let i = 0; i < options.keywords.length; i++) {\n const keyword = options.keywords[i];\n\n if (!isString(keyword)) {\n throw new Error(\"'options.keywords' expected an array containing string values\");\n }\n }\n\n out.keywords = options.keywords;\n }\n\n if (options.contentUrl) {\n if (!isString(options.contentUrl)) {\n throw new Error(\"'options.contentUrl' expected a string value\");\n }\n\n if (!isValidUrl(options.contentUrl)) {\n throw new Error(\"'options.contentUrl' expected a valid HTTP or HTTPS url.\");\n }\n\n if (options.contentUrl.length > 512) {\n throw new Error(\"'options.contentUrl' maximum length of a content URL is 512 characters.\");\n }\n\n out.contentUrl = options.contentUrl;\n }\n\n if (options.location) {\n const error = new Error(\n \"'options.location' expected an array value containing a latitude & longitude number value.\",\n );\n\n if (!isArray(options.location)) {\n throw error;\n }\n\n const [latitude, longitude] = options.location;\n\n if (!isNumber(latitude) || !isNumber(longitude)) {\n throw error;\n }\n\n if (latitude < -90 || latitude > 90) {\n throw new Error(\n `'options.location' latitude value must be a number between -90 and 90, but was: ${latitude}`,\n );\n }\n\n if (longitude < -180 || longitude > 180) {\n throw new Error(\n `'options.location' longitude value must be a number between -180 and 180, but was: ${latitude}`,\n );\n }\n\n out.location = [latitude, longitude];\n }\n\n if (hasOwnProperty(options, 'locationAccuracy')) {\n if (!isNumber(options.locationAccuracy)) {\n throw new Error(\"'options.locationAccuracy' expected a number value.\");\n }\n\n if (isNumber(options.locationAccuracy) && options.locationAccuracy < 0) {\n throw new Error(\"'options.locationAccuracy' expected a number greater than 0.\");\n }\n\n out.locationAccuracy = options.locationAccuracy;\n } else {\n out.locationAccuracy = 5;\n }\n\n if (options.requestAgent) {\n if (!isString(options.requestAgent)) {\n throw new Error(\"'options.requestAgent' expected a string value\");\n }\n\n out.requestAgent = options.requestAgent;\n }\n\n if (options.serverSideVerificationOptions) {\n if (!isObject(options.serverSideVerificationOptions)) {\n throw new Error(\n \"'options.serverSideVerificationOptions' expected an object of key/value pairs\",\n );\n }\n\n const ssvOptions = options.serverSideVerificationOptions;\n\n if (ssvOptions.userId && !isString(ssvOptions.userId)) {\n throw new Error(\"'options.serverSideVerificationOptions.userId' expected a string value\");\n }\n\n if (ssvOptions.customData && !isString(ssvOptions.customData)) {\n throw new Error(\"'options.serverSideVerificationOptions.customData' expected a string value\");\n }\n\n out.serverSideVerificationOptions = options.serverSideVerificationOptions;\n }\n\n if (options.customTargeting) {\n if (!isObject(options.customTargeting)) {\n throw new Error(\"'options.customTargeting' expected an object of key/value pairs\");\n }\n out.customTargeting = options.customTargeting;\n }\n\n return out;\n}\n"]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '5.0.0';\n"]}
|
package/lib/module/AdsConsent.js
CHANGED
|
@@ -14,134 +14,64 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
import { hasOwnProperty, isArray, isBoolean, isObject, isString
|
|
17
|
+
import { hasOwnProperty, isArray, isBoolean, isObject, isString } from './common';
|
|
18
18
|
import { NativeModules } from 'react-native';
|
|
19
19
|
import { AdsConsentDebugGeography } from './AdsConsentDebugGeography';
|
|
20
|
-
import { AdsConsentStatus } from './AdsConsentStatus';
|
|
21
20
|
const native = NativeModules.RNGoogleMobileAdsConsentModule;
|
|
22
21
|
export const AdsConsent = {
|
|
23
22
|
/**
|
|
24
23
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @
|
|
24
|
+
* @param {Object} [options]
|
|
25
|
+
* @param {AdsConsentDebugGeography} [options.debugGeography]
|
|
26
|
+
* @param {Boolean} [options.tagForUnderAgeOfConsent]
|
|
27
|
+
* @param {Array<String>} [options.testDeviceIdentifiers]
|
|
28
|
+
* @returns {{ status: Number, isConsentFormAvailable: Boolean }}
|
|
27
29
|
*/
|
|
28
|
-
requestInfoUpdate(
|
|
29
|
-
|
|
30
|
-
throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (publisherIds.length === 0) {
|
|
34
|
-
throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
for (let i = 0; i < publisherIds.length; i++) {
|
|
38
|
-
if (!isString(publisherIds[i])) {
|
|
39
|
-
throw new Error(`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
30
|
+
requestInfoUpdate() {
|
|
31
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param options
|
|
49
|
-
* @returns {*}
|
|
50
|
-
*/
|
|
51
|
-
showForm(options) {
|
|
52
|
-
if (!isUndefined(options) && !isObject(options)) {
|
|
53
|
-
throw new Error("AdsConsent.showForm(*) 'options' expected an object value.");
|
|
33
|
+
if (!isObject(options)) {
|
|
34
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value.");
|
|
54
35
|
}
|
|
55
36
|
|
|
56
|
-
if (
|
|
57
|
-
throw new Error("AdsConsent.
|
|
37
|
+
if (hasOwnProperty(options, 'debugGeography') && options.debugGeography !== AdsConsentDebugGeography.DISABLED && options.debugGeography !== AdsConsentDebugGeography.EEA && options.debugGeography !== AdsConsentDebugGeography.NOT_EEA) {
|
|
38
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.");
|
|
58
39
|
}
|
|
59
40
|
|
|
60
|
-
if (hasOwnProperty(options, '
|
|
61
|
-
throw new Error("AdsConsent.
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (hasOwnProperty(options, 'withNonPersonalizedAds') && !isBoolean(options.withNonPersonalizedAds)) {
|
|
65
|
-
throw new Error("AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value.");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (hasOwnProperty(options, 'withAdFree') && !isBoolean(options.withAdFree)) {
|
|
69
|
-
throw new Error("AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value.");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) {
|
|
73
|
-
throw new Error("AdsConsent.showForm(*) 'options' form requires at least one option to be enabled.");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return native.showForm(options);
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
*/
|
|
82
|
-
getAdProviders() {
|
|
83
|
-
return native.getAdProviders();
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
*
|
|
88
|
-
* @param geography
|
|
89
|
-
*/
|
|
90
|
-
setDebugGeography(geography) {
|
|
91
|
-
if (geography !== AdsConsentDebugGeography.DISABLED && geography !== AdsConsentDebugGeography.EEA && geography !== AdsConsentDebugGeography.NOT_EEA) {
|
|
92
|
-
throw new Error("AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.");
|
|
41
|
+
if (hasOwnProperty(options, 'tagForUnderAgeOfConsent') && !isBoolean(options.tagForUnderAgeOfConsent)) {
|
|
42
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.");
|
|
93
43
|
}
|
|
94
44
|
|
|
95
|
-
|
|
96
|
-
|
|
45
|
+
if (hasOwnProperty(options, 'testDeviceIdentifiers')) {
|
|
46
|
+
if (!isArray(options.testDeviceIdentifiers)) {
|
|
47
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.");
|
|
48
|
+
}
|
|
97
49
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*/
|
|
101
|
-
getStatus() {
|
|
102
|
-
return native.getStatus();
|
|
103
|
-
},
|
|
50
|
+
for (const deviceId of (_options$testDeviceId = options.testDeviceIdentifiers) !== null && _options$testDeviceId !== void 0 ? _options$testDeviceId : []) {
|
|
51
|
+
var _options$testDeviceId;
|
|
104
52
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
setStatus(status) {
|
|
110
|
-
if (status !== AdsConsentStatus.UNKNOWN && status !== AdsConsentStatus.NON_PERSONALIZED && status !== AdsConsentStatus.PERSONALIZED) {
|
|
111
|
-
throw new Error("AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED.");
|
|
53
|
+
if (!isString(deviceId)) {
|
|
54
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
112
57
|
}
|
|
113
58
|
|
|
114
|
-
return native.
|
|
59
|
+
return native.requestInfoUpdate(options);
|
|
115
60
|
},
|
|
116
61
|
|
|
117
62
|
/**
|
|
118
63
|
*
|
|
119
|
-
* @
|
|
64
|
+
* @returns {{ status: Number }}
|
|
120
65
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value.");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return native.setTagForUnderAgeOfConsent(tag);
|
|
66
|
+
showForm() {
|
|
67
|
+
return native.showForm();
|
|
127
68
|
},
|
|
128
69
|
|
|
129
70
|
/**
|
|
130
71
|
*
|
|
131
|
-
* @param deviceIds
|
|
132
72
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.");
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
for (let i = 0; i < deviceIds.length; i++) {
|
|
139
|
-
if (!isString(deviceIds[i])) {
|
|
140
|
-
throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.");
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return native.addTestDevices(deviceIds);
|
|
73
|
+
reset() {
|
|
74
|
+
return native.reset();
|
|
145
75
|
}
|
|
146
76
|
|
|
147
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["AdsConsent.ts"],"names":["hasOwnProperty","isArray","isBoolean","isObject","isString","
|
|
1
|
+
{"version":3,"sources":["AdsConsent.ts"],"names":["hasOwnProperty","isArray","isBoolean","isObject","isString","NativeModules","AdsConsentDebugGeography","native","RNGoogleMobileAdsConsentModule","AdsConsent","requestInfoUpdate","options","Error","debugGeography","DISABLED","EEA","NOT_EEA","tagForUnderAgeOfConsent","testDeviceIdentifiers","deviceId","showForm","reset"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,cAAT,EAAyBC,OAAzB,EAAkCC,SAAlC,EAA6CC,QAA7C,EAAuDC,QAAvD,QAAuE,UAAvE;AACA,SAASC,aAAT,QAA8B,cAA9B;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AAGA,MAAMC,MAAM,GAAGF,aAAa,CAACG,8BAA7B;AAEA,OAAO,MAAMC,UAA+B,GAAG;AAC7C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,iBAAiB,GAAe;AAAA,QAAdC,OAAc,uEAAJ,EAAI;;AAC9B,QAAI,CAACR,QAAQ,CAACQ,OAAD,CAAb,EAAwB;AACtB,YAAM,IAAIC,KAAJ,CAAU,qEAAV,CAAN;AACD;;AAED,QACEZ,cAAc,CAACW,OAAD,EAAU,gBAAV,CAAd,IACAA,OAAO,CAACE,cAAR,KAA2BP,wBAAwB,CAACQ,QADpD,IAEAH,OAAO,CAACE,cAAR,KAA2BP,wBAAwB,CAACS,GAFpD,IAGAJ,OAAO,CAACE,cAAR,KAA2BP,wBAAwB,CAACU,OAJtD,EAKE;AACA,YAAM,IAAIJ,KAAJ,CACJ,+KADI,CAAN;AAGD;;AAED,QACEZ,cAAc,CAACW,OAAD,EAAU,yBAAV,CAAd,IACA,CAACT,SAAS,CAACS,OAAO,CAACM,uBAAT,CAFZ,EAGE;AACA,YAAM,IAAIL,KAAJ,CACJ,6FADI,CAAN;AAGD;;AAED,QAAIZ,cAAc,CAACW,OAAD,EAAU,uBAAV,CAAlB,EAAsD;AACpD,UAAI,CAACV,OAAO,CAACU,OAAO,CAACO,qBAAT,CAAZ,EAA6C;AAC3C,cAAM,IAAIN,KAAJ,CACJ,qGADI,CAAN;AAGD;;AAED,WAAK,MAAMO,QAAX,6BAAuBR,OAAO,CAACO,qBAA/B,yEAAwD,EAAxD,EAA4D;AAAA;;AAC1D,YAAI,CAACd,QAAQ,CAACe,QAAD,CAAb,EAAyB;AACvB,gBAAM,IAAIP,KAAJ,CACJ,qGADI,CAAN;AAGD;AACF;AACF;;AAED,WAAOL,MAAM,CAACG,iBAAP,CAAyBC,OAAzB,CAAP;AACD,GAnD4C;;AAqD7C;AACF;AACA;AACA;AACES,EAAAA,QAAQ,GAAG;AACT,WAAOb,MAAM,CAACa,QAAP,EAAP;AACD,GA3D4C;;AA6D7C;AACF;AACA;AACEC,EAAAA,KAAK,GAAG;AACN,WAAOd,MAAM,CAACc,KAAP,EAAP;AACD;;AAlE4C,CAAxC","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\nimport { hasOwnProperty, isArray, isBoolean, isObject, isString } from './common';\nimport { NativeModules } from 'react-native';\nimport { AdsConsentDebugGeography } from './AdsConsentDebugGeography';\nimport { AdsConsentInterface } from './types/AdsConsent.interface';\n\nconst native = NativeModules.RNGoogleMobileAdsConsentModule;\n\nexport const AdsConsent: AdsConsentInterface = {\n /**\n *\n * @param {Object} [options]\n * @param {AdsConsentDebugGeography} [options.debugGeography]\n * @param {Boolean} [options.tagForUnderAgeOfConsent]\n * @param {Array<String>} [options.testDeviceIdentifiers]\n * @returns {{ status: Number, isConsentFormAvailable: Boolean }}\n */\n requestInfoUpdate(options = {}) {\n if (!isObject(options)) {\n throw new Error(\"AdsConsent.requestInfoUpdate(*) 'options' expected an object value.\");\n }\n\n if (\n hasOwnProperty(options, 'debugGeography') &&\n options.debugGeography !== AdsConsentDebugGeography.DISABLED &&\n options.debugGeography !== AdsConsentDebugGeography.EEA &&\n options.debugGeography !== AdsConsentDebugGeography.NOT_EEA\n ) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.\",\n );\n }\n\n if (\n hasOwnProperty(options, 'tagForUnderAgeOfConsent') &&\n !isBoolean(options.tagForUnderAgeOfConsent)\n ) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.\",\n );\n }\n\n if (hasOwnProperty(options, 'testDeviceIdentifiers')) {\n if (!isArray(options.testDeviceIdentifiers)) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.\",\n );\n }\n\n for (const deviceId of options.testDeviceIdentifiers ?? []) {\n if (!isString(deviceId)) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.\",\n );\n }\n }\n }\n\n return native.requestInfoUpdate(options);\n },\n\n /**\n *\n * @returns {{ status: Number }}\n */\n showForm() {\n return native.showForm();\n },\n\n /**\n *\n */\n reset() {\n return native.reset();\n },\n};\n"]}
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
export let AdsConsentStatus;
|
|
22
22
|
|
|
23
23
|
(function (AdsConsentStatus) {
|
|
24
|
-
AdsConsentStatus[
|
|
25
|
-
AdsConsentStatus[
|
|
26
|
-
AdsConsentStatus[
|
|
24
|
+
AdsConsentStatus["UNKNOWN"] = "UNKNOWN";
|
|
25
|
+
AdsConsentStatus["REQUIRED"] = "REQUIRED";
|
|
26
|
+
AdsConsentStatus["NOT_REQUIRED"] = "NOT_REQUIRED";
|
|
27
|
+
AdsConsentStatus["OBTAINED"] = "OBTAINED";
|
|
27
28
|
})(AdsConsentStatus || (AdsConsentStatus = {}));
|
|
28
29
|
//# sourceMappingURL=AdsConsentStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["AdsConsentStatus.ts"],"names":["AdsConsentStatus"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAYA,gBAAZ;;WAAYA,gB;AAAAA,EAAAA,gB,
|
|
1
|
+
{"version":3,"sources":["AdsConsentStatus.ts"],"names":["AdsConsentStatus"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAYA,gBAAZ;;WAAYA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,KAAAA,gB","sourcesContent":["/*\n * Copyright (c) 2016-present Invertase Limited & Contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this library except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\n/**\n * AdsConsentStatus enum.\n */\nexport enum AdsConsentStatus {\n /**\n * Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it.\n */\n UNKNOWN = 'UNKNOWN',\n\n /**\n * User consent required but not yet obtained.\n */\n REQUIRED = 'REQUIRED',\n\n /**\n * User consent not required.\n */\n NOT_REQUIRED = 'NOT_REQUIRED',\n\n /**\n * User consent already obtained.\n */\n OBTAINED = 'OBTAINED',\n}\n"]}
|
|
@@ -145,6 +145,14 @@ export function validateAdRequestOptions(options) {
|
|
|
145
145
|
out.serverSideVerificationOptions = options.serverSideVerificationOptions;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
if (options.customTargeting) {
|
|
149
|
+
if (!isObject(options.customTargeting)) {
|
|
150
|
+
throw new Error("'options.customTargeting' expected an object of key/value pairs");
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
out.customTargeting = options.customTargeting;
|
|
154
|
+
}
|
|
155
|
+
|
|
148
156
|
return out;
|
|
149
157
|
}
|
|
150
158
|
//# sourceMappingURL=validateAdRequestOptions.js.map
|