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