react-native-google-mobile-ads 4.2.0 → 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/ReactNativeGoogleMobileAdsConsentModule.java +100 -171
- 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 +2 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +0 -1
- package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +71 -126
- 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/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/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/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/version.ts +1 -1
|
@@ -9,246 +9,81 @@ import { AdsConsentStatus } from '../AdsConsentStatus';
|
|
|
9
9
|
* It is recommended that you determine the status of a user's consent at every app launch. The user consent status is held
|
|
10
10
|
* on the device until a condition changes which requires the user to consent again, such as a change in publishers.
|
|
11
11
|
*
|
|
12
|
-
* For more information, see [here](https://developers.google.com/admob/android/
|
|
12
|
+
* For more information, see [here](https://developers.google.com/admob/ump/android/quick-start#delay_app_measurement_optional).
|
|
13
13
|
*/
|
|
14
|
-
/**
|
|
15
|
-
* A AdProvider interface returned from `AdsConsent.getProviders`.
|
|
16
|
-
*/
|
|
17
|
-
export interface AdProvider {
|
|
18
|
-
/**
|
|
19
|
-
* A provider company ID.
|
|
20
|
-
*/
|
|
21
|
-
companyId: string;
|
|
22
|
-
/**
|
|
23
|
-
* A provider company name.
|
|
24
|
-
*/
|
|
25
|
-
companyName: string;
|
|
26
|
-
/**
|
|
27
|
-
* A fully formed URL for the privacy policy of the provider.
|
|
28
|
-
*/
|
|
29
|
-
privacyPolicyUrl: string;
|
|
30
|
-
}
|
|
31
14
|
export interface AdsConsentInterface {
|
|
32
15
|
/**
|
|
33
|
-
* Requests user consent
|
|
34
|
-
*
|
|
35
|
-
* The list of publisher IDs can be obtained from the settings panel on the Google Mobile Ads console. If the list of
|
|
36
|
-
* publisher IDs has changed since the last time a user provided consent, their consent status will be reset to
|
|
37
|
-
* 'UNKNOWN' and they must provide consent again.
|
|
38
|
-
*
|
|
39
|
-
* If the request fails with the error "Could not parse Event FE preflight response", this means the state of your
|
|
40
|
-
* Google Mobile Ads account is not complete. Ensure you have validated your account and have setup valid payment
|
|
41
|
-
* information. This error is also thrown when a Publisher ID is invalid.
|
|
16
|
+
* Requests user consent information.
|
|
42
17
|
*
|
|
43
|
-
* The response from this method provides
|
|
44
|
-
*
|
|
45
|
-
* If request location is within the EEA or unknown, and the consent status is also unknown, you
|
|
46
|
-
* must request consent via the `showForm()` method or your own means.
|
|
47
|
-
*
|
|
48
|
-
* If the consent status is not unknown, the user has already previously provided consent for the current publisher
|
|
49
|
-
* scope.
|
|
18
|
+
* The response from this method provides information about consent form availability and consent status.
|
|
50
19
|
*
|
|
51
20
|
* #### Example
|
|
52
21
|
*
|
|
53
22
|
* ```js
|
|
54
23
|
* import { AdsConsent } from 'react-native-google-mobile-ads';
|
|
55
24
|
*
|
|
56
|
-
* const
|
|
57
|
-
* console.log('
|
|
58
|
-
* console.log('User consent status:',
|
|
25
|
+
* const consentInfo = await AdsConsent.requestInfoUpdate();
|
|
26
|
+
* console.log('A consent form is available:', consentInfo.isConsentFormAvailable);
|
|
27
|
+
* console.log('User consent status:', consentInfo.status);
|
|
59
28
|
* ```
|
|
60
|
-
*
|
|
61
|
-
* @param publisherIds A list of publisher IDs found on your Google Mobile Ads dashboard.
|
|
29
|
+
* @param options An AdsConsentInfoOptions interface.
|
|
62
30
|
*/
|
|
63
|
-
requestInfoUpdate(
|
|
31
|
+
requestInfoUpdate(options?: AdsConsentInfoOptions): Promise<AdsConsentInfo>;
|
|
64
32
|
/**
|
|
65
33
|
* Shows a Google-rendered user consent form.
|
|
66
34
|
*
|
|
67
|
-
* The Google-rendered consent form is a full-screen configurable form that displays over your app content. The form
|
|
68
|
-
* allows the following configuration options:
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* 1. Consent to view personalized ads (via `withPersonalizedAds`).
|
|
72
|
-
* 2. Consent to view non-personalized ads (via `withNonPersonalizedAds`).
|
|
73
|
-
* 3. Use a paid version of the app instead of viewing ads (via `withAdFree`).
|
|
74
|
-
*
|
|
75
|
-
* Every consent form requires a privacy policy URL which outlines the usage of your application.
|
|
76
|
-
*
|
|
77
|
-
* You should review the consent text carefully: what appears by default is a message that might be appropriate if
|
|
78
|
-
* you use Google to monetize your app.
|
|
79
|
-
*
|
|
80
|
-
* If providing an ad-free version of your app, ensure you handle this once the form has been handled by the user
|
|
81
|
-
* via the `userPrefersAdFree` property. The users preference on consent is automatically forwarded onto the Google
|
|
82
|
-
* Mobile SDKs and saved.
|
|
83
|
-
*
|
|
84
|
-
* If the user is outside of the EEA, the request form will error.
|
|
85
|
-
*
|
|
86
35
|
* #### Example
|
|
87
36
|
*
|
|
88
37
|
* ```js
|
|
89
38
|
* import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
|
|
90
39
|
*
|
|
91
40
|
* async function requestConsent() {
|
|
92
|
-
* const
|
|
41
|
+
* const consentInfo = await AdsConsent.requestInfoUpdate();
|
|
93
42
|
*
|
|
94
43
|
* // Check if user requires consent
|
|
95
|
-
* if (
|
|
44
|
+
* if (
|
|
45
|
+
* consentInfo.isConsentFormAvailable &&
|
|
46
|
+
* (consentInfo.status === AdsConsentStatus.UNKNOWN ||
|
|
47
|
+
* consentInfo.status === AdsConsentStatus.REQUIRED)) {
|
|
96
48
|
* // Show a Google-rendered form
|
|
97
|
-
* const
|
|
98
|
-
* privacyPolicy: 'https://invertase.io/privacy-policy',
|
|
99
|
-
* withPersonalizedAds: true,
|
|
100
|
-
* withNonPersonalizedAds: true,
|
|
101
|
-
* withAdFree: true,
|
|
102
|
-
* });
|
|
49
|
+
* const formResult = await AdsConsent.showForm();
|
|
103
50
|
*
|
|
104
|
-
* console.log('User
|
|
105
|
-
* console.log('User accepted non-personalized: ', result.status === AdsConsentStatus.NON_PERSONALIZED);
|
|
106
|
-
* console.log('User prefers Ad Free version of app: ', result.userPrefersAdFree);
|
|
51
|
+
* console.log('User consent obtained: ', formResult.status === AdsConsentStatus.OBTAINED);
|
|
107
52
|
* }
|
|
108
53
|
* }
|
|
109
54
|
*
|
|
110
55
|
* ```
|
|
111
|
-
*
|
|
112
|
-
* @param options An AdsConsentFormOptions interface to control the Google-rendered form.
|
|
113
|
-
*/
|
|
114
|
-
showForm(options: AdsConsentFormOptions): Promise<AdsConsentFormResult>;
|
|
115
|
-
/**
|
|
116
|
-
* Returns a list of ad providers currently in use for the given Google Mobile Ads App ID.
|
|
117
|
-
*
|
|
118
|
-
* If requesting consent from the user via your own method, this list of ad providers must be shown to the user
|
|
119
|
-
* for them to accept consent.
|
|
120
|
-
*
|
|
121
|
-
* #### Example
|
|
122
|
-
*
|
|
123
|
-
* ```js
|
|
124
|
-
* import { AdsConsent } from 'react-native-google-mobile-ads';
|
|
125
|
-
*
|
|
126
|
-
* const providers = await AdsConsent.getAdProviders();
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
getAdProviders(): Promise<AdProvider[]>;
|
|
130
|
-
/**
|
|
131
|
-
* Sets the debug geography to locally test consent.
|
|
132
|
-
*
|
|
133
|
-
* If debugging on an emulator (where location cannot be determined) or outside of the EEA,
|
|
134
|
-
* it is possible set your own location to test how your app handles different scenarios.
|
|
135
|
-
*
|
|
136
|
-
* If using a real device, ensure you have set it as a test device via `addTestDevice()` otherwise this method will have
|
|
137
|
-
* no effect.
|
|
138
|
-
*
|
|
139
|
-
* #### Example
|
|
140
|
-
*
|
|
141
|
-
* ```js
|
|
142
|
-
* import { AdsConsent, AdsConsentDebugGeography } from 'react-native-google-mobile-ads';
|
|
143
|
-
*
|
|
144
|
-
* // Set disabled
|
|
145
|
-
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.DISABLED);
|
|
146
|
-
*
|
|
147
|
-
* // Set within EEA
|
|
148
|
-
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.EEA);
|
|
149
|
-
*
|
|
150
|
-
* // Set outside EEA
|
|
151
|
-
* await AdsConsentDebugGeography.setDebugGeography(AdsConsentDebugGeography.NOT_EEA);
|
|
152
|
-
* ```
|
|
153
|
-
*
|
|
154
|
-
* @param geography The debug geography location.
|
|
155
|
-
*/
|
|
156
|
-
setDebugGeography(geography: AdsConsentDebugGeography): Promise<void>;
|
|
157
|
-
/**
|
|
158
|
-
* Manually update the consent status of the user.
|
|
159
|
-
*
|
|
160
|
-
* This method is used when providing your own means of user consent. If using the Google-rendered form via `showForm()`,
|
|
161
|
-
* the consent status is automatically set and calling this method is not required.
|
|
162
|
-
*
|
|
163
|
-
* This method can also be used to reset the consent status, by setting it to `AdsConsentStatus.UNKNOWN`, which may be useful in certain circumstances.
|
|
164
|
-
*
|
|
165
|
-
* #### Example
|
|
166
|
-
*
|
|
167
|
-
* ```js
|
|
168
|
-
* import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
|
|
169
|
-
*
|
|
170
|
-
* // User accepted personalized ads
|
|
171
|
-
* await AdsConsent.setStatus(AdsConsentStatus.PERSONALIZED);
|
|
172
|
-
* ```
|
|
173
|
-
*
|
|
174
|
-
* @param status The user consent status.
|
|
175
|
-
*/
|
|
176
|
-
setStatus(status: AdsConsentStatus): Promise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* Returns the current consent status of the user.
|
|
179
|
-
*
|
|
180
|
-
* > The user consent status may change at any time, therefore don't reuse old values locally and always request the current value at any time consent is required.
|
|
181
|
-
*
|
|
182
|
-
* #### Example
|
|
183
|
-
*
|
|
184
|
-
* ```js
|
|
185
|
-
* import { AdsConsent } from 'react-native-google-mobile-ads';
|
|
186
|
-
*
|
|
187
|
-
* const status = await AdsConsent.getStatus();
|
|
188
|
-
* ```
|
|
189
56
|
*/
|
|
190
|
-
|
|
57
|
+
showForm(): Promise<AdsConsentFormResult>;
|
|
191
58
|
/**
|
|
192
|
-
*
|
|
193
|
-
* Under the Age of consent in Europe). This setting takes effect for all future ad requests.
|
|
194
|
-
*
|
|
195
|
-
* Once the TFUA setting is enabled, the Google-rendered consent form will fail to load. All ad requests that include
|
|
196
|
-
* TFUA will be made ineligible for personalized advertising and remarketing. TFUA disables requests to third-party
|
|
197
|
-
* ad technology providers, such as ad measurement pixels and third-party ad servers.
|
|
198
|
-
*
|
|
199
|
-
* To remove TFUA from ad requests, set the value to `false`.
|
|
59
|
+
* Resets the UMP SDK state.
|
|
200
60
|
*
|
|
201
61
|
* #### Example
|
|
202
62
|
*
|
|
203
63
|
* ```js
|
|
204
|
-
* import { AdsConsent } from 'react-native-google-
|
|
64
|
+
* import { AdsConsent } from '@invertase/react-native-google-ads';
|
|
205
65
|
*
|
|
206
|
-
*
|
|
207
|
-
* await AdsConsent.setTagForUnderAgeOfConsent(true);
|
|
66
|
+
* AdsConsent.reset();
|
|
208
67
|
* ```
|
|
209
|
-
*
|
|
210
|
-
* @param tag The boolean value to tag for under age consent.
|
|
211
68
|
*/
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* If using a real device to test, ensure the device ID is provided to the Google Mobile Ads SDK so any mock debug locations
|
|
215
|
-
* can take effect.
|
|
216
|
-
*
|
|
217
|
-
* Emulators are automatically on the allowlist and should require no action.
|
|
218
|
-
*
|
|
219
|
-
* If you are seeing real ad activity from a test device, examine logcat / console
|
|
220
|
-
* during execution in association with google mobile ads test device documentation to
|
|
221
|
-
* configure your device correctly.
|
|
222
|
-
*
|
|
223
|
-
* @param deviceIds An array of testing device ID.
|
|
224
|
-
*/
|
|
225
|
-
addTestDevices(deviceIds: string[]): Promise<void>;
|
|
69
|
+
reset(): void;
|
|
226
70
|
}
|
|
227
71
|
/**
|
|
228
|
-
* The options used
|
|
72
|
+
* The options used when requesting consent information.
|
|
229
73
|
*/
|
|
230
|
-
export interface
|
|
74
|
+
export interface AdsConsentInfoOptions {
|
|
231
75
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* Users will have the option to visit this web page before consenting to ads.
|
|
76
|
+
* Sets the debug geography to locally test consent.
|
|
235
77
|
*/
|
|
236
|
-
|
|
78
|
+
debugGeography?: AdsConsentDebugGeography;
|
|
237
79
|
/**
|
|
238
80
|
* Set to `true` to provide the option for the user to accept being shown personalized ads, defaults to `false`.
|
|
239
81
|
*/
|
|
240
|
-
|
|
82
|
+
tagForUnderAgeOfConsent?: boolean;
|
|
241
83
|
/**
|
|
242
|
-
*
|
|
84
|
+
* An array of test device IDs to allow.
|
|
243
85
|
*/
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Set to `true` to provide the option for the user to choose an ad-free version of your app, defaults to `false`.
|
|
247
|
-
*
|
|
248
|
-
* If the user chooses this option, you must handle it as required (e.g. navigating to a paid version of the app,
|
|
249
|
-
* or a subscribe view).
|
|
250
|
-
*/
|
|
251
|
-
withAdFree?: boolean;
|
|
86
|
+
testDeviceIdentifiers?: string[];
|
|
252
87
|
}
|
|
253
88
|
/**
|
|
254
89
|
* The result of a Google-rendered consent form.
|
|
@@ -257,15 +92,12 @@ export interface AdsConsentFormResult {
|
|
|
257
92
|
/**
|
|
258
93
|
* The consent status of the user after closing the consent form.
|
|
259
94
|
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
95
|
+
* - `UNKNOWN`: Unknown consent status.
|
|
96
|
+
* - `REQUIRED`: User consent required but not yet obtained.
|
|
97
|
+
* - `NOT_REQUIRED`: User consent not required.
|
|
98
|
+
* - `OBTAINED`: User consent already obtained.
|
|
263
99
|
*/
|
|
264
100
|
status: AdsConsentStatus;
|
|
265
|
-
/**
|
|
266
|
-
* If `true`, the user requested an ad-free version of your application.
|
|
267
|
-
*/
|
|
268
|
-
userPrefersAdFree: boolean;
|
|
269
101
|
}
|
|
270
102
|
/**
|
|
271
103
|
* The result of requesting info about a users consent status.
|
|
@@ -274,13 +106,14 @@ export interface AdsConsentInfo {
|
|
|
274
106
|
/**
|
|
275
107
|
* The consent status of the user.
|
|
276
108
|
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
109
|
+
* - `UNKNOWN`: Unknown consent status.
|
|
110
|
+
* - `REQUIRED`: User consent required but not yet obtained.
|
|
111
|
+
* - `NOT_REQUIRED`: User consent not required.
|
|
112
|
+
* - `OBTAINED`: User consent already obtained.
|
|
280
113
|
*/
|
|
281
114
|
status: AdsConsentStatus;
|
|
282
115
|
/**
|
|
283
|
-
* If `true`
|
|
116
|
+
* If `true` a consent form is available.
|
|
284
117
|
*/
|
|
285
|
-
|
|
118
|
+
isConsentFormAvailable: boolean;
|
|
286
119
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "5.0.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-google-mobile-ads",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
5
|
"description": "React Native Google Mobile Ads is an easy way to monetize mobile apps with targeted, in-app advertising.",
|
|
6
6
|
"main": "lib/commonjs/index.js",
|
|
@@ -41,14 +41,16 @@
|
|
|
41
41
|
],
|
|
42
42
|
"sdkVersions": {
|
|
43
43
|
"ios": {
|
|
44
|
-
"
|
|
44
|
+
"googleMobileAds": "8.13.0",
|
|
45
|
+
"googleUmp": "2.0.0"
|
|
45
46
|
},
|
|
46
47
|
"android": {
|
|
47
48
|
"minSdk": 16,
|
|
48
49
|
"targetSdk": 30,
|
|
49
50
|
"compileSdk": 31,
|
|
50
51
|
"buildTools": "31.0.0",
|
|
51
|
-
"
|
|
52
|
+
"googleMobileAds": "20.5.0",
|
|
53
|
+
"googleUmp": "2.0.0"
|
|
52
54
|
}
|
|
53
55
|
},
|
|
54
56
|
"react-native-builder-bob": {
|
package/src/AdsConsent.ts
CHANGED
|
@@ -15,18 +15,9 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
hasOwnProperty,
|
|
20
|
-
isArray,
|
|
21
|
-
isBoolean,
|
|
22
|
-
isObject,
|
|
23
|
-
isString,
|
|
24
|
-
isUndefined,
|
|
25
|
-
isValidUrl,
|
|
26
|
-
} from './common';
|
|
18
|
+
import { hasOwnProperty, isArray, isBoolean, isObject, isString } from './common';
|
|
27
19
|
import { NativeModules } from 'react-native';
|
|
28
20
|
import { AdsConsentDebugGeography } from './AdsConsentDebugGeography';
|
|
29
|
-
import { AdsConsentStatus } from './AdsConsentStatus';
|
|
30
21
|
import { AdsConsentInterface } from './types/AdsConsent.interface';
|
|
31
22
|
|
|
32
23
|
const native = NativeModules.RNGoogleMobileAdsConsentModule;
|
|
@@ -34,158 +25,68 @@ const native = NativeModules.RNGoogleMobileAdsConsentModule;
|
|
|
34
25
|
export const AdsConsent: AdsConsentInterface = {
|
|
35
26
|
/**
|
|
36
27
|
*
|
|
37
|
-
* @param
|
|
38
|
-
* @
|
|
28
|
+
* @param {Object} [options]
|
|
29
|
+
* @param {AdsConsentDebugGeography} [options.debugGeography]
|
|
30
|
+
* @param {Boolean} [options.tagForUnderAgeOfConsent]
|
|
31
|
+
* @param {Array<String>} [options.testDeviceIdentifiers]
|
|
32
|
+
* @returns {{ status: Number, isConsentFormAvailable: Boolean }}
|
|
39
33
|
*/
|
|
40
|
-
requestInfoUpdate(
|
|
41
|
-
if (!
|
|
42
|
-
throw new Error(
|
|
43
|
-
"AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.",
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (publisherIds.length === 0) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
"AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.",
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
for (let i = 0; i < publisherIds.length; i++) {
|
|
54
|
-
if (!isString(publisherIds[i])) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return native.requestInfoUpdate(publisherIds);
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
* @param options
|
|
67
|
-
* @returns {*}
|
|
68
|
-
*/
|
|
69
|
-
showForm(options) {
|
|
70
|
-
if (!isUndefined(options) && !isObject(options)) {
|
|
71
|
-
throw new Error("AdsConsent.showForm(*) 'options' expected an object value.");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!isValidUrl(options.privacyPolicy)) {
|
|
75
|
-
throw new Error(
|
|
76
|
-
"AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.",
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (hasOwnProperty(options, 'withPersonalizedAds') && !isBoolean(options.withPersonalizedAds)) {
|
|
81
|
-
throw new Error(
|
|
82
|
-
"AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.",
|
|
83
|
-
);
|
|
34
|
+
requestInfoUpdate(options = {}) {
|
|
35
|
+
if (!isObject(options)) {
|
|
36
|
+
throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value.");
|
|
84
37
|
}
|
|
85
38
|
|
|
86
39
|
if (
|
|
87
|
-
hasOwnProperty(options, '
|
|
88
|
-
|
|
40
|
+
hasOwnProperty(options, 'debugGeography') &&
|
|
41
|
+
options.debugGeography !== AdsConsentDebugGeography.DISABLED &&
|
|
42
|
+
options.debugGeography !== AdsConsentDebugGeography.EEA &&
|
|
43
|
+
options.debugGeography !== AdsConsentDebugGeography.NOT_EEA
|
|
89
44
|
) {
|
|
90
45
|
throw new Error(
|
|
91
|
-
"AdsConsent.
|
|
46
|
+
"AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.",
|
|
92
47
|
);
|
|
93
48
|
}
|
|
94
49
|
|
|
95
|
-
if (hasOwnProperty(options, 'withAdFree') && !isBoolean(options.withAdFree)) {
|
|
96
|
-
throw new Error("AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value.");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) {
|
|
100
|
-
throw new Error(
|
|
101
|
-
"AdsConsent.showForm(*) 'options' form requires at least one option to be enabled.",
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return native.showForm(options);
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
|
-
getAdProviders() {
|
|
112
|
-
return native.getAdProviders();
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
*
|
|
117
|
-
* @param geography
|
|
118
|
-
*/
|
|
119
|
-
setDebugGeography(geography) {
|
|
120
50
|
if (
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
geography !== AdsConsentDebugGeography.NOT_EEA
|
|
51
|
+
hasOwnProperty(options, 'tagForUnderAgeOfConsent') &&
|
|
52
|
+
!isBoolean(options.tagForUnderAgeOfConsent)
|
|
124
53
|
) {
|
|
125
54
|
throw new Error(
|
|
126
|
-
"AdsConsent.
|
|
55
|
+
"AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.",
|
|
127
56
|
);
|
|
128
57
|
}
|
|
129
58
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
getStatus() {
|
|
137
|
-
return native.getStatus();
|
|
138
|
-
},
|
|
59
|
+
if (hasOwnProperty(options, 'testDeviceIdentifiers')) {
|
|
60
|
+
if (!isArray(options.testDeviceIdentifiers)) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.",
|
|
63
|
+
);
|
|
64
|
+
}
|
|
139
65
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
status !== AdsConsentStatus.NON_PERSONALIZED &&
|
|
148
|
-
status !== AdsConsentStatus.PERSONALIZED
|
|
149
|
-
) {
|
|
150
|
-
throw new Error(
|
|
151
|
-
"AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED.",
|
|
152
|
-
);
|
|
66
|
+
for (const deviceId of options.testDeviceIdentifiers ?? []) {
|
|
67
|
+
if (!isString(deviceId)) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
"AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.",
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
153
73
|
}
|
|
154
74
|
|
|
155
|
-
return native.
|
|
75
|
+
return native.requestInfoUpdate(options);
|
|
156
76
|
},
|
|
157
77
|
|
|
158
78
|
/**
|
|
159
79
|
*
|
|
160
|
-
* @
|
|
80
|
+
* @returns {{ status: Number }}
|
|
161
81
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value.");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return native.setTagForUnderAgeOfConsent(tag);
|
|
82
|
+
showForm() {
|
|
83
|
+
return native.showForm();
|
|
168
84
|
},
|
|
169
85
|
|
|
170
86
|
/**
|
|
171
87
|
*
|
|
172
|
-
* @param deviceIds
|
|
173
88
|
*/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
throw new Error(
|
|
177
|
-
"AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.",
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
for (let i = 0; i < deviceIds.length; i++) {
|
|
182
|
-
if (!isString(deviceIds[i])) {
|
|
183
|
-
throw new Error(
|
|
184
|
-
"AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.",
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return native.addTestDevices(deviceIds);
|
|
89
|
+
reset() {
|
|
90
|
+
return native.reset();
|
|
190
91
|
},
|
|
191
92
|
};
|
package/src/AdsConsentStatus.ts
CHANGED
|
@@ -20,17 +20,22 @@
|
|
|
20
20
|
*/
|
|
21
21
|
export enum AdsConsentStatus {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Unknown consent status, AdsConsent.requestInfoUpdate needs to be called to update it.
|
|
24
24
|
*/
|
|
25
|
-
UNKNOWN =
|
|
25
|
+
UNKNOWN = 'UNKNOWN',
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* User consent required but not yet obtained.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
REQUIRED = 'REQUIRED',
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* User consent not required.
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
NOT_REQUIRED = 'NOT_REQUIRED',
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* User consent already obtained.
|
|
39
|
+
*/
|
|
40
|
+
OBTAINED = 'OBTAINED',
|
|
36
41
|
}
|