react-native-google-mobile-ads 5.0.1 → 5.1.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.
Files changed (71) hide show
  1. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +19 -5
  2. package/docs/common-reasons-for-ads-not-showing.mdx +26 -24
  3. package/docs/displaying-ads-hook.mdx +99 -0
  4. package/docs/displaying-ads.mdx +3 -4
  5. package/docs/european-user-consent.mdx +34 -5
  6. package/docs/index.mdx +4 -4
  7. package/docs/migrating-to-v5.mdx +17 -8
  8. package/docs.json +2 -1
  9. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +14 -0
  10. package/lib/commonjs/AdsConsent.js +47 -16
  11. package/lib/commonjs/AdsConsent.js.map +1 -1
  12. package/lib/commonjs/AdsConsentPurposes.js +47 -0
  13. package/lib/commonjs/AdsConsentPurposes.js.map +1 -0
  14. package/lib/commonjs/AdsConsentSpecialFeatures.js +39 -0
  15. package/lib/commonjs/AdsConsentSpecialFeatures.js.map +1 -0
  16. package/lib/commonjs/hooks/useAppOpenAd.js +51 -0
  17. package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -0
  18. package/lib/commonjs/hooks/useFullScreenAd.js +120 -0
  19. package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -0
  20. package/lib/commonjs/hooks/useInterstitialAd.js +51 -0
  21. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
  22. package/lib/commonjs/hooks/useRewardedAd.js +51 -0
  23. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
  24. package/lib/commonjs/index.js +40 -0
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/types/AdStates.js +6 -0
  27. package/lib/commonjs/types/AdStates.js.map +1 -0
  28. package/lib/commonjs/version.js +1 -1
  29. package/lib/commonjs/version.js.map +1 -1
  30. package/lib/module/AdsConsent.js +44 -16
  31. package/lib/module/AdsConsent.js.map +1 -1
  32. package/lib/module/AdsConsentPurposes.js +39 -0
  33. package/lib/module/AdsConsentPurposes.js.map +1 -0
  34. package/lib/module/AdsConsentSpecialFeatures.js +31 -0
  35. package/lib/module/AdsConsentSpecialFeatures.js.map +1 -0
  36. package/lib/module/hooks/useAppOpenAd.js +38 -0
  37. package/lib/module/hooks/useAppOpenAd.js.map +1 -0
  38. package/lib/module/hooks/useFullScreenAd.js +109 -0
  39. package/lib/module/hooks/useFullScreenAd.js.map +1 -0
  40. package/lib/module/hooks/useInterstitialAd.js +38 -0
  41. package/lib/module/hooks/useInterstitialAd.js.map +1 -0
  42. package/lib/module/hooks/useRewardedAd.js +38 -0
  43. package/lib/module/hooks/useRewardedAd.js.map +1 -0
  44. package/lib/module/index.js +5 -0
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/types/AdStates.js +2 -0
  47. package/lib/module/types/AdStates.js.map +1 -0
  48. package/lib/module/version.js +1 -1
  49. package/lib/module/version.js.map +1 -1
  50. package/lib/typescript/AdsConsentPurposes.d.ts +148 -0
  51. package/lib/typescript/AdsConsentSpecialFeatures.d.ts +22 -0
  52. package/lib/typescript/hooks/useAppOpenAd.d.ts +9 -0
  53. package/lib/typescript/hooks/useFullScreenAd.d.ts +5 -0
  54. package/lib/typescript/hooks/useInterstitialAd.d.ts +9 -0
  55. package/lib/typescript/hooks/useRewardedAd.d.ts +9 -0
  56. package/lib/typescript/index.d.ts +6 -1
  57. package/lib/typescript/types/AdStates.d.ts +85 -0
  58. package/lib/typescript/types/AdsConsent.interface.d.ts +216 -0
  59. package/lib/typescript/version.d.ts +1 -1
  60. package/package.json +6 -2
  61. package/src/AdsConsent.ts +75 -20
  62. package/src/AdsConsentPurposes.ts +182 -0
  63. package/src/AdsConsentSpecialFeatures.ts +48 -0
  64. package/src/hooks/useAppOpenAd.ts +46 -0
  65. package/src/hooks/useFullScreenAd.ts +104 -0
  66. package/src/hooks/useInterstitialAd.ts +46 -0
  67. package/src/hooks/useRewardedAd.ts +46 -0
  68. package/src/index.ts +5 -0
  69. package/src/types/AdStates.ts +87 -0
  70. package/src/types/AdsConsent.interface.ts +220 -0
  71. package/src/version.ts +1 -1
@@ -16,11 +16,13 @@ package io.invertase.googlemobileads;
16
16
  * limitations under the License.
17
17
  *
18
18
  */
19
-
19
+ import android.content.SharedPreferences;
20
+ import android.preference.PreferenceManager;
20
21
  import com.facebook.react.bridge.Arguments;
21
22
  import com.facebook.react.bridge.Promise;
22
23
  import com.facebook.react.bridge.ReactApplicationContext;
23
24
  import com.facebook.react.bridge.ReactMethod;
25
+ import com.facebook.react.bridge.ReadableArray;
24
26
  import com.facebook.react.bridge.ReadableMap;
25
27
  import com.facebook.react.bridge.WritableMap;
26
28
  import com.google.android.ump.ConsentDebugSettings;
@@ -28,7 +30,6 @@ import com.google.android.ump.ConsentInformation;
28
30
  import com.google.android.ump.ConsentRequestParameters;
29
31
  import com.google.android.ump.UserMessagingPlatform;
30
32
  import io.invertase.googlemobileads.common.ReactNativeModule;
31
- import java.util.List;
32
33
  import javax.annotation.Nonnull;
33
34
 
34
35
  public class ReactNativeGoogleMobileAdsConsentModule extends ReactNativeModule {
@@ -63,10 +64,10 @@ public class ReactNativeGoogleMobileAdsConsentModule extends ReactNativeModule {
63
64
  new ConsentDebugSettings.Builder(getApplicationContext());
64
65
 
65
66
  if (options.hasKey("testDeviceIdentifiers")) {
66
- List<Object> devices = options.getArray("testDeviceIdentifiers").toArrayList();
67
+ ReadableArray devices = options.getArray("testDeviceIdentifiers");
67
68
 
68
- for (Object device : devices) {
69
- debugSettingsBuilder.addTestDeviceHashedId((String) device);
69
+ for (int i = 0; i < devices.size(); i++) {
70
+ debugSettingsBuilder.addTestDeviceHashedId(devices.getString(i));
70
71
  }
71
72
  }
72
73
 
@@ -152,4 +153,17 @@ public class ReactNativeGoogleMobileAdsConsentModule extends ReactNativeModule {
152
153
  public void reset() {
153
154
  consentInformation.reset();
154
155
  }
156
+
157
+ @ReactMethod
158
+ public void getTCString(Promise promise) {
159
+ try {
160
+ SharedPreferences prefs =
161
+ PreferenceManager.getDefaultSharedPreferences(getReactApplicationContext());
162
+ // https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#in-app-details
163
+ String tcString = prefs.getString("IABTCF_TCString", null);
164
+ promise.resolve(tcString);
165
+ } catch (Exception e) {
166
+ rejectPromiseWithCodeAndMessage(promise, "consent-string-error", e.toString());
167
+ }
168
+ }
155
169
  }
@@ -13,6 +13,7 @@ You'll be notified of approval or rejection via email after review.
13
13
 
14
14
  New apps and ad units take some time to activate.
15
15
  Here are common reasons you may not see live impressions immediately:
16
+
16
17
  - It usually takes at least an hour after you create an app or ad unit
17
18
  - Sometimes it can take a few days for ads to appear in new apps or ad units
18
19
  - New iOS apps will not show Google ads until they’re listed in the Apple App Store
@@ -35,6 +36,7 @@ Test devices can either be added in the AdMob UI or programmatically using the G
35
36
  Follow the steps below to add your device as a test device.
36
37
 
37
38
  #### Add your test device in the AdMob UI
39
+
38
40
  For a simple, non-programmatic way to add a test device and test new or existing app builds, use the AdMob UI.
39
41
  [Learn how](https://support.google.com/admob/answer/9691433).
40
42
 
@@ -48,39 +50,39 @@ If you want to test ads in your app as you're developing, follow the steps below
48
50
 
49
51
  3. Check the console for a message that looks like this:
50
52
 
51
- ```
52
- GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers =
53
- @[ @"2077ef9a63d2b398840261c8221a0c9b" ]; // Sample device ID
54
- ```
53
+ ```
54
+ GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers =
55
+ @[ @"2077ef9a63d2b398840261c8221a0c9b" ]; // Sample device ID
56
+ ```
55
57
 
56
- Copy your test device ID to your clipboard.
58
+ Copy your test device ID to your clipboard.
57
59
 
58
60
  4. Check the logcat output for a message that looks like the one below, which shows you your device ID and how to add it as a test device:
59
61
 
60
- ```
61
- I/Ads: Use RequestConfiguration.Builder.setTestDeviceIds(Arrays.asList("33BE2250B43518CCDA7DE426D04EE231"))
62
- to get test ads on this device."
63
- ```
62
+ ```
63
+ I/Ads: Use RequestConfiguration.Builder.setTestDeviceIds(Arrays.asList("33BE2250B43518CCDA7DE426D04EE231"))
64
+ to get test ads on this device."
65
+ ```
64
66
 
65
- Copy your test device ID to your clipboard.
67
+ Copy your test device ID to your clipboard.
66
68
 
67
69
  5. Modify your code to set the test device ID through testDeviceIdentifiers
68
70
 
69
- ```js
70
- import mobileAds from 'react-native-google-mobile-ads';
71
+ ```js
72
+ import mobileAds from 'react-native-google-mobile-ads';
71
73
 
72
- mobileAds()
73
- .setRequestConfiguration({
74
- // An array of test device IDs to add to the allow list.
75
- testDeviceIdentifiers: ["2077ef9a63d2b398840261c8221a0c9b", "EMULATOR"]
76
- })
77
- .then(() => {
78
- // Request config successfully set!
79
- });
80
- ```
74
+ mobileAds()
75
+ .setRequestConfiguration({
76
+ // An array of test device IDs to add to the allow list.
77
+ testDeviceIdentifiers: ['2077ef9a63d2b398840261c8221a0c9b', 'EMULATOR'],
78
+ })
79
+ .then(() => {
80
+ // Request config successfully set!
81
+ });
82
+ ```
81
83
 
82
- 5. Re-run your app. If the ad is a Google ad, you'll see a Test Ad label centered at the top of the ad.
83
- Ads with this Test Ad label are safe to click. Requests, impressions, and clicks on test ads will not show up in your account's reports.
84
+ 6. Re-run your app. If the ad is a Google ad, you'll see a Test Ad label centered at the top of the ad.
85
+ Ads with this Test Ad label are safe to click. Requests, impressions, and clicks on test ads will not show up in your account's reports.
84
86
 
85
87
  ## Emulator vs real device
86
88
 
@@ -89,4 +91,4 @@ In some cases ads won't show up on an emulator but will show up while testing on
89
91
  ## Extra links
90
92
 
91
93
  - Mobile Ads SDK [iOS](https://developers.google.com/admob/ios/quick-start), [Android](https://developers.google.com/admob/android/quick-start)
92
- - [Common reasons for ads not showing](https://support.google.com/admob/answer/9469204)
94
+ - [Common reasons for ads not showing](https://support.google.com/admob/answer/9469204)
@@ -0,0 +1,99 @@
1
+ # Hooks
2
+
3
+ The AdMob package provides hooks to help you to display ads in a functional component with tiny code. The supported ad formats are full-screen ads: App open, Interstitial & Rewarded.
4
+
5
+ ## Load an ad
6
+
7
+ You can create a new ad by adding a corresponding ad type's hook to your component.
8
+
9
+ The first argument of the hook is the "Ad Unit ID".
10
+ For testing, we can use a Test ID, however for production the ID from the
11
+ Google AdMob dashboard under "Ad units" should be used:
12
+
13
+ ```tsx {4-8}
14
+ import { useInterstitialAd, TestIds } from 'react-native-google-mobile-ads';
15
+
16
+ export default function App() {
17
+ const interstitialAd = useInterstitialAd(TestIds.Interstitial, {
18
+ requestNonPersonalizedAdsOnly: true,
19
+ });
20
+
21
+ return <View>{/* ... */}</View>;
22
+ }
23
+ ```
24
+
25
+ > The `adUnitid` parameter can also be used to manage creation and destruction of an ad instance.
26
+ > If `adUnitid` is set or changed, new ad instance will be created and previous ad instance will be destroyed if exists.
27
+ > If `adUnitid` is set to `null`, no ad instance will be created and previous ad instance will be destroyed if exists.
28
+
29
+ The second argument is an additional optional request options object to be sent whilst loading an advert, such as keywords & location.
30
+ Setting additional request options helps AdMob choose better tailored ads from the network. View the [`RequestOptions`](/reference/admob/requestoptions)
31
+ documentation to view the full range of options available.
32
+
33
+ ## Show the ad
34
+
35
+ The hook returns several states and functions to control ad.
36
+
37
+ ```tsx
38
+ import { useInterstitialAd, TestIds } from 'react-native-google-mobile-ads';
39
+
40
+ export default function App({ navigation }) {
41
+ const { isLoaded, isClosed, load, show } = useInterstitialAd(TestIds.Interstitial, {
42
+ requestNonPersonalizedAdsOnly: true,
43
+ });
44
+
45
+ useEffect(() => {
46
+ // Start loading the interstitial straight away
47
+ load();
48
+ }, [load]);
49
+
50
+ useEffect(() => {
51
+ if (isClosed) {
52
+ // Action after the ad is closed
53
+ navigation.navigate('NextScreen');
54
+ }
55
+ }, [isClosed, navigation]);
56
+
57
+ return (
58
+ <View>
59
+ <Button
60
+ title="Navigate to next screen"
61
+ onPress={() => {
62
+ if (isLoaded) {
63
+ show();
64
+ } else {
65
+ // No advert ready to show yet
66
+ navigation.navigate('NextScreen');
67
+ }
68
+ }}
69
+ />
70
+ </View>
71
+ );
72
+ }
73
+ ```
74
+
75
+ The code above immediately starts to load a new advert from the network (via `load()`).
76
+ When user presses button, it checks if the ad is loaded via `isLoaded` value,
77
+ then the `show` function is called and the advert is shown over-the-top of your application.
78
+ Otherwise, if the ad is not loaded, the `navigation.navigate` method is called to navigate to the next screen without showing the ad.
79
+ After the ad is closed, the `isClosed` value is set to `true` and the `navigation.navigate` method is called to navigate to the next screen.
80
+
81
+ If needed, you can reuse the existing hook to load more adverts and show them when required. The states are initialized when the `load` function is called.
82
+
83
+ Return values of the hook are:
84
+
85
+ | Name | Type | Description |
86
+ | :------------- | :--------------------------------- | :----------------------------------------------------------------------------------------------------------------- |
87
+ | isLoaded | boolean | Whether the ad is loaded and ready to to be shown to the user. |
88
+ | isOpened | boolean | Whether the ad is opened. The value is remained `true` even after the ad is closed unless **new ad is requested**. |
89
+ | isClosed | boolean | Whether your ad is dismissed. |
90
+ | isShowing | boolean | Whether your ad is showing. The value is equal with `isOpened && !isClosed`. |
91
+ | error | Error \| undefined | `Error` object throwed during ad load. |
92
+ | reward | [RewardedAdReward](#) \| undefined | Loaded reward item of the Rewarded Ad. Available only in RewardedAd. |
93
+ | isEarnedReward | boolean | Whether the user earned the reward by Rewarded Ad. |
94
+ | load | Function | Start loading the advert with the provided RequestOptions. |
95
+ | show | Function | Show the loaded advert to the user. |
96
+
97
+ > Note that `isOpened` value remains `true` even after the ad is closed.
98
+ > The value changes to `false` when ad is initialized via calling `load()`.
99
+ > To determine whether the ad is currently showing, use `isShowing` value.
@@ -27,11 +27,10 @@ const appOpenAd = AppOpenAd.createForAdRequest(adUnitId, {
27
27
  });
28
28
 
29
29
  // Preload an app open ad
30
- appOpenAd.load()
30
+ appOpenAd.load();
31
31
 
32
32
  // Show the app open ad when user brings the app to the foreground.
33
- appOpenAd.show()
34
-
33
+ appOpenAd.show();
35
34
  ```
36
35
 
37
36
  ### Consider ad expiration
@@ -159,7 +158,7 @@ The purpose of a rewarded ad is to reward users with _something_ after completin
159
158
  as watching a video or submitting an option via an interactive form. If the user completes the action, you can reward them
160
159
  with something (e.g. in-game currency).
161
160
 
162
- To create a new interstitial, call the `createForAdRequest` method from the `RewardedAd` class. The first argument
161
+ To create a new rewarded ad, call the `createForAdRequest` method from the `RewardedAd` class. The first argument
163
162
  of the method is the "Ad Unit ID". For testing, we can use a Test ID, however for production the ID from the
164
163
  Google AdMob dashboard under "Ad units" should be used:
165
164
 
@@ -93,16 +93,45 @@ import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
93
93
 
94
94
  const consentInfo = await AdsConsent.requestInfoUpdate();
95
95
 
96
- if (
97
- consentInfo.isConsentFormAvailable &&
98
- consentInfo.status === AdsConsentStatus.REQUIRED
99
- ) {
96
+ if (consentInfo.isConsentFormAvailable && consentInfo.status === AdsConsentStatus.REQUIRED) {
100
97
  const { status } = await AdsConsent.showForm();
101
98
  }
102
99
  ```
103
100
 
104
101
  > Do not persist the status. You could however store this locally in application state (e.g. React Context) and update the status on every app launch as it may change.
105
102
 
103
+ ### Inspecting consent choices
104
+
105
+ The AdsConsentStatus tells you if you should show the modal to a user or not. Often times you want to run logic based on the user's choices though.
106
+ Especially since the Google Mobile Ads SDK won't show any ads if the user didn't give consent to store and/or access information on the device.
107
+ This library exports a method that returns some of the most relevant consent flags to handle common use cases.
108
+
109
+ ```js
110
+ import { AdsConsent } from 'react-native-google-mobile-ads';
111
+
112
+ const {
113
+ activelyScanDeviceCharacteristicsForIdentification,
114
+ applyMarketResearchToGenerateAudienceInsights,
115
+ createAPersonalisedAdsProfile,
116
+ createAPersonalisedContentProfile,
117
+ developAndImproveProducts,
118
+ measureAdPerformance,
119
+ measureContentPerformance,
120
+ selectBasicAds,
121
+ selectPersonalisedAds,
122
+ selectPersonalisedContent,
123
+ storeAndAccessInformationOnDevice,
124
+ usePreciseGeolocationData,
125
+ } = await AdsConsent.getUserChoices();
126
+
127
+ if (storeAndAccessInformationOnDevice === false) {
128
+ /**
129
+ * The user declined consent for purpose 1,
130
+ * the Google Mobile Ads SDK won't serve ads.
131
+ */
132
+ }
133
+ ```
134
+
106
135
  ### Testing
107
136
 
108
137
  When developing the consent flow, the behavior of the `AdsConsent` responses may not be reliable due to the environment
@@ -136,5 +165,5 @@ It is possible to reset the UMP state for test devices. To reset the ATT state y
136
165
  ```js
137
166
  import { AdsConsent } from 'react-native-google-mobile-ads';
138
167
 
139
- AdsConsent.reset()
168
+ AdsConsent.reset();
140
169
  ```
package/docs/index.mdx CHANGED
@@ -14,7 +14,7 @@ a [Google AdMob account](https://apps.admob.com) is required.
14
14
 
15
15
  <YouTube id="9qCxo0D-Sak" />
16
16
 
17
- The module supports three types of Ads:
17
+ The module supports four types of Ads:
18
18
 
19
19
  1. Full screen [App Open Ads](/displaying-ads#app-open-ads).
20
20
  2. Full screen [Interstitial Ads](/displaying-ads#interstitial-ads).
@@ -94,7 +94,7 @@ mobileAds()
94
94
  tagForUnderAgeOfConsent: true,
95
95
 
96
96
  // An array of test device IDs to allow.
97
- testDeviceIdentifiers: ["EMULATOR"]
97
+ testDeviceIdentifiers: ['EMULATOR'],
98
98
  })
99
99
  .then(() => {
100
100
  // Request config successfully set!
@@ -109,14 +109,14 @@ Before loading ads, have your app initialize the Google Mobile Ads SDK by callin
109
109
  This needs to be done only once, ideally at app launch.
110
110
 
111
111
  > ⚠️ **Warning:** Ads may be preloaded by the Mobile Ads SDK or mediation partner SDKs upon calling `initialize`.
112
- If you need to obtain consent from users in the European Economic Area (EEA), set any request-specific flags (such as tagForChildDirectedTreatment), or otherwise take action before loading ads, ensure you do so before initializing the Mobile Ads SDK.
112
+ > If you need to obtain consent from users in the European Economic Area (EEA), set any request-specific flags (such as tagForChildDirectedTreatment), or otherwise take action before loading ads, ensure you do so before initializing the Mobile Ads SDK.
113
113
 
114
114
  ```js
115
115
  import mobileAds from 'react-native-google-mobile-ads';
116
116
 
117
117
  mobileAds()
118
118
  .initialize()
119
- .then((adapterStatuses) => {
119
+ .then(adapterStatuses => {
120
120
  // Initialization complete!
121
121
  });
122
122
  ```
@@ -13,13 +13,13 @@ Please refer to the following links for more information:
13
13
 
14
14
  Previously it was possible to request the ad providers and to update the consent status. This is no longer the case.
15
15
  Also, while the old Consent SDK provided information about user preferences, the new `AdsConsentStatus` only tells you if you should show the modal to a user or not.
16
- You can read the `IABTCF_TCString` key from standardUserDefaults / SharedPreferences and decode it with a library like [@iabtcf/core](https://github.com/InteractiveAdvertisingBureau/iabtcf-es/tree/master/modules/core#iabtcfcore) though.
17
16
 
18
- * `requestInfoUpdate` does now accept an optional `AdsConsentInfoOptions` object instead of expecting `publisherIds` and returns a changed `AdsConsentInfo` interface
19
- * `showForm` does not expect any parameters any longer and now only returns the changed `AdsConsentStatus` as part of it's `AdsConsentFormResult` interface
20
- * `getAdProviders`, `getStatus` and `setStatus` methods were removed without replacements
21
- * `addTestDevices`, `setDebugGeography` and `setTagForUnderAgeOfConsent` methods were removed, but their functionality is available via `AdsConsentInfoOptions`
22
- * the `user_tracking_usage_description` key is needed in your project's `app.json` if you want to handle Apple's App Tracking Transparency
17
+ - `requestInfoUpdate` does now accept an optional `AdsConsentInfoOptions` object instead of expecting `publisherIds` and returns a changed `AdsConsentInfo` interface
18
+ - `showForm` does not expect any parameters any longer and now only returns the changed `AdsConsentStatus` as part of it's `AdsConsentFormResult` interface
19
+ - `getAdProviders`, `getStatus` and `setStatus` methods were removed without replacements
20
+ - `addTestDevices`, `setDebugGeography` and `setTagForUnderAgeOfConsent` methods were removed, but their functionality is available via `AdsConsentInfoOptions`
21
+ - the `user_tracking_usage_description` key is needed in your project's `app.json` if you want to handle Apple's App Tracking Transparency
22
+ - newly added `getUserChoices` can be used to inspect some of the consent choices
23
23
 
24
24
  ```diff
25
25
  {
@@ -33,10 +33,10 @@ You can read the `IABTCF_TCString` key from standardUserDefaults / SharedPrefere
33
33
 
34
34
  ```diff
35
35
  import { AdsConsent, AdsConsentStatus } from 'react-native-google-mobile-ads';
36
-
36
+
37
37
  -const consentInfo = await AdsConsent.requestInfoUpdate(['pub-6189033257628123']);
38
38
  +const consentInfo = await AdsConsent.requestInfoUpdate();
39
-
39
+
40
40
  if (
41
41
  - consentInfo.isRequestLocationInEeaOrUnknown &&
42
42
  + consentInfo.isConsentFormAvailable &&
@@ -50,5 +50,14 @@ You can read the `IABTCF_TCString` key from standardUserDefaults / SharedPrefere
50
50
  - withAdFree: true,
51
51
  - });
52
52
  + const formResult = await AdsConsent.showForm()
53
+ +
54
+ + const { storeAndAccessInformationOnDevice } = await AdsConsent.getUserChoices();
55
+ +
56
+ + if (storeAndAccessInformationOnDevice === false) {
57
+ + /**
58
+ + * The user declined consent for purpose 1,
59
+ + * the Google Mobile Ads SDK won't serve ads.
60
+ + */
61
+ + }
53
62
  }
54
63
  ```
package/docs.json CHANGED
@@ -4,8 +4,9 @@
4
4
  "sidebar": [
5
5
  ["Installation", "/"],
6
6
  ["Displaying Ads", "/displaying-ads"],
7
+ ["Displaying Ads via Hook", "/displaying-ads-hook"],
7
8
  ["European User Consent", "/european-user-consent"],
8
9
  ["Common Reasons For Ads Not Showing", "/common-reasons-for-ads-not-showing"],
9
10
  ["Migrating to v5", "/migrating-to-v5"]
10
11
  ]
11
- }
12
+ }
@@ -121,4 +121,18 @@ RCT_EXPORT_METHOD(showForm : (RCTPromiseResolveBlock)resolve : (RCTPromiseReject
121
121
 
122
122
  RCT_EXPORT_METHOD(reset) { [UMPConsentInformation.sharedInstance reset]; }
123
123
 
124
+ RCT_EXPORT_METHOD(getTCString : (RCTPromiseResolveBlock)resolve : (RCTPromiseRejectBlock)reject) {
125
+ @try {
126
+ // https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#in-app-details
127
+ NSString *tcString = [[NSUserDefaults standardUserDefaults] objectForKey:@"IABTCF_TCString"];
128
+ resolve(tcString);
129
+ } @catch (NSError *error) {
130
+ [RNSharedUtils rejectPromiseWithUserInfo:reject
131
+ userInfo:[@{
132
+ @"code" : @"consent-string-error",
133
+ @"message" : error.localizedDescription,
134
+ } mutableCopy]];
135
+ }
136
+ }
137
+
124
138
  @end
@@ -5,12 +5,18 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.AdsConsent = void 0;
7
7
 
8
- var _common = require("./common");
8
+ var _core = require("@iabtcf/core");
9
9
 
10
10
  var _reactNative = require("react-native");
11
11
 
12
12
  var _AdsConsentDebugGeography = require("./AdsConsentDebugGeography");
13
13
 
14
+ var _AdsConsentPurposes = require("./AdsConsentPurposes");
15
+
16
+ var _AdsConsentSpecialFeatures = require("./AdsConsentSpecialFeatures");
17
+
18
+ var _common = require("./common");
19
+
14
20
  /*
15
21
  * Copyright (c) 2016-present Invertase Limited & Contributors
16
22
  *
@@ -29,14 +35,6 @@ var _AdsConsentDebugGeography = require("./AdsConsentDebugGeography");
29
35
  */
30
36
  const native = _reactNative.NativeModules.RNGoogleMobileAdsConsentModule;
31
37
  const AdsConsent = {
32
- /**
33
- *
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 }}
39
- */
40
38
  requestInfoUpdate() {
41
39
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
42
40
 
@@ -69,19 +67,52 @@ const AdsConsent = {
69
67
  return native.requestInfoUpdate(options);
70
68
  },
71
69
 
72
- /**
73
- *
74
- * @returns {{ status: Number }}
75
- */
76
70
  showForm() {
77
71
  return native.showForm();
78
72
  },
79
73
 
80
- /**
81
- *
82
- */
83
74
  reset() {
84
75
  return native.reset();
76
+ },
77
+
78
+ getTCString() {
79
+ return native.getTCString();
80
+ },
81
+
82
+ async getTCModel() {
83
+ const tcString = await native.getTCString();
84
+ return _core.TCString.decode(tcString);
85
+ },
86
+
87
+ async getUserChoices() {
88
+ const tcString = await native.getTCString();
89
+ let tcModel;
90
+
91
+ try {
92
+ tcModel = _core.TCString.decode(tcString);
93
+ } catch (e) {
94
+ tcModel = new _core.TCModel();
95
+
96
+ if (__DEV__) {
97
+ // eslint-disable-next-line no-console
98
+ console.warn(`Failed to decode tcString ${tcString}:`, e);
99
+ }
100
+ }
101
+
102
+ return {
103
+ activelyScanDeviceCharacteristicsForIdentification: tcModel.specialFeatureOptins.has(_AdsConsentSpecialFeatures.AdsConsentSpecialFeatures.ACTIVELY_SCAN_DEVICE_CHARACTERISTICS_FOR_IDENTIFICATION),
104
+ applyMarketResearchToGenerateAudienceInsights: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.APPLY_MARKET_RESEARCH_TO_GENERATE_AUDIENCE_INSIGHTS),
105
+ createAPersonalisedAdsProfile: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.CREATE_A_PERSONALISED_ADS_PROFILE),
106
+ createAPersonalisedContentProfile: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.CREATE_A_PERSONALISED_ADS_PROFILE),
107
+ developAndImproveProducts: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.DEVELOP_AND_IMPROVE_PRODUCTS),
108
+ measureAdPerformance: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.MEASURE_AD_PERFORMANCE),
109
+ measureContentPerformance: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.MEASURE_CONTENT_PERFORMANCE),
110
+ selectBasicAds: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.SELECT_BASIC_ADS),
111
+ selectPersonalisedAds: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.SELECT_PERSONALISED_ADS),
112
+ selectPersonalisedContent: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.SELECT_PERSONALISED_CONTENT),
113
+ storeAndAccessInformationOnDevice: tcModel.purposeConsents.has(_AdsConsentPurposes.AdsConsentPurposes.STORE_AND_ACCESS_INFORMATION_ON_DEVICE),
114
+ usePreciseGeolocationData: tcModel.specialFeatureOptins.has(_AdsConsentSpecialFeatures.AdsConsentSpecialFeatures.USE_PRECISE_GEOLOCATION_DATA)
115
+ };
85
116
  }
86
117
 
87
118
  };
@@ -1 +1 @@
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"]}
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","getTCString","getTCModel","tcString","TCString","decode","getUserChoices","tcModel","e","TCModel","__DEV__","console","warn","activelyScanDeviceCharacteristicsForIdentification","specialFeatureOptins","has","AdsConsentSpecialFeatures","ACTIVELY_SCAN_DEVICE_CHARACTERISTICS_FOR_IDENTIFICATION","applyMarketResearchToGenerateAudienceInsights","purposeConsents","AdsConsentPurposes","APPLY_MARKET_RESEARCH_TO_GENERATE_AUDIENCE_INSIGHTS","createAPersonalisedAdsProfile","CREATE_A_PERSONALISED_ADS_PROFILE","createAPersonalisedContentProfile","developAndImproveProducts","DEVELOP_AND_IMPROVE_PRODUCTS","measureAdPerformance","MEASURE_AD_PERFORMANCE","measureContentPerformance","MEASURE_CONTENT_PERFORMANCE","selectBasicAds","SELECT_BASIC_ADS","selectPersonalisedAds","SELECT_PERSONALISED_ADS","selectPersonalisedContent","SELECT_PERSONALISED_CONTENT","storeAndAccessInformationOnDevice","STORE_AND_ACCESS_INFORMATION_ON_DEVICE","usePreciseGeolocationData","USE_PRECISE_GEOLOCATION_DATA"],"mappings":"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","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 { TCModel, TCString } from '@iabtcf/core';\nimport { NativeModules } from 'react-native';\nimport { AdsConsentDebugGeography } from './AdsConsentDebugGeography';\nimport { AdsConsentPurposes } from './AdsConsentPurposes';\nimport { AdsConsentSpecialFeatures } from './AdsConsentSpecialFeatures';\nimport { hasOwnProperty, isArray, isBoolean, isObject, isString } from './common';\nimport {\n AdsConsentFormResult,\n AdsConsentInfo,\n AdsConsentInfoOptions,\n AdsConsentInterface,\n AdsConsentUserChoices,\n} from './types/AdsConsent.interface';\n\nconst native = NativeModules.RNGoogleMobileAdsConsentModule;\n\nexport const AdsConsent: AdsConsentInterface = {\n requestInfoUpdate(options: AdsConsentInfoOptions = {}): Promise<AdsConsentInfo> {\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 showForm(): Promise<AdsConsentFormResult> {\n return native.showForm();\n },\n\n reset(): void {\n return native.reset();\n },\n\n getTCString(): Promise<string> {\n return native.getTCString();\n },\n\n async getTCModel(): Promise<TCModel> {\n const tcString = await native.getTCString();\n return TCString.decode(tcString);\n },\n\n async getUserChoices(): Promise<AdsConsentUserChoices> {\n const tcString = await native.getTCString();\n\n let tcModel: TCModel;\n\n try {\n tcModel = TCString.decode(tcString);\n } catch (e) {\n tcModel = new TCModel();\n\n if (__DEV__) {\n // eslint-disable-next-line no-console\n console.warn(`Failed to decode tcString ${tcString}:`, e);\n }\n }\n\n return {\n activelyScanDeviceCharacteristicsForIdentification: tcModel.specialFeatureOptins.has(\n AdsConsentSpecialFeatures.ACTIVELY_SCAN_DEVICE_CHARACTERISTICS_FOR_IDENTIFICATION,\n ),\n applyMarketResearchToGenerateAudienceInsights: tcModel.purposeConsents.has(\n AdsConsentPurposes.APPLY_MARKET_RESEARCH_TO_GENERATE_AUDIENCE_INSIGHTS,\n ),\n createAPersonalisedAdsProfile: tcModel.purposeConsents.has(\n AdsConsentPurposes.CREATE_A_PERSONALISED_ADS_PROFILE,\n ),\n createAPersonalisedContentProfile: tcModel.purposeConsents.has(\n AdsConsentPurposes.CREATE_A_PERSONALISED_ADS_PROFILE,\n ),\n developAndImproveProducts: tcModel.purposeConsents.has(\n AdsConsentPurposes.DEVELOP_AND_IMPROVE_PRODUCTS,\n ),\n measureAdPerformance: tcModel.purposeConsents.has(AdsConsentPurposes.MEASURE_AD_PERFORMANCE),\n measureContentPerformance: tcModel.purposeConsents.has(\n AdsConsentPurposes.MEASURE_CONTENT_PERFORMANCE,\n ),\n selectBasicAds: tcModel.purposeConsents.has(AdsConsentPurposes.SELECT_BASIC_ADS),\n selectPersonalisedAds: tcModel.purposeConsents.has(\n AdsConsentPurposes.SELECT_PERSONALISED_ADS,\n ),\n selectPersonalisedContent: tcModel.purposeConsents.has(\n AdsConsentPurposes.SELECT_PERSONALISED_CONTENT,\n ),\n storeAndAccessInformationOnDevice: tcModel.purposeConsents.has(\n AdsConsentPurposes.STORE_AND_ACCESS_INFORMATION_ON_DEVICE,\n ),\n usePreciseGeolocationData: tcModel.specialFeatureOptins.has(\n AdsConsentSpecialFeatures.USE_PRECISE_GEOLOCATION_DATA,\n ),\n };\n },\n};\n"]}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AdsConsentPurposes = void 0;
7
+
8
+ /*
9
+ * Copyright (c) 2016-present Invertase Limited & Contributors
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this library except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ *
23
+ *
24
+ *
25
+ *
26
+ * The definitions in this document are copied from IAB's global vendor list.
27
+ *
28
+ * https://vendor-list.consensu.org/v2/vendor-list.json
29
+ * https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework
30
+ *
31
+ */
32
+ let AdsConsentPurposes;
33
+ exports.AdsConsentPurposes = AdsConsentPurposes;
34
+
35
+ (function (AdsConsentPurposes) {
36
+ AdsConsentPurposes[AdsConsentPurposes["STORE_AND_ACCESS_INFORMATION_ON_DEVICE"] = 1] = "STORE_AND_ACCESS_INFORMATION_ON_DEVICE";
37
+ AdsConsentPurposes[AdsConsentPurposes["SELECT_BASIC_ADS"] = 2] = "SELECT_BASIC_ADS";
38
+ AdsConsentPurposes[AdsConsentPurposes["CREATE_A_PERSONALISED_ADS_PROFILE"] = 3] = "CREATE_A_PERSONALISED_ADS_PROFILE";
39
+ AdsConsentPurposes[AdsConsentPurposes["SELECT_PERSONALISED_ADS"] = 4] = "SELECT_PERSONALISED_ADS";
40
+ AdsConsentPurposes[AdsConsentPurposes["CREATE_A_PERSONALISED_CONTENT_PROFILE"] = 5] = "CREATE_A_PERSONALISED_CONTENT_PROFILE";
41
+ AdsConsentPurposes[AdsConsentPurposes["SELECT_PERSONALISED_CONTENT"] = 6] = "SELECT_PERSONALISED_CONTENT";
42
+ AdsConsentPurposes[AdsConsentPurposes["MEASURE_AD_PERFORMANCE"] = 7] = "MEASURE_AD_PERFORMANCE";
43
+ AdsConsentPurposes[AdsConsentPurposes["MEASURE_CONTENT_PERFORMANCE"] = 8] = "MEASURE_CONTENT_PERFORMANCE";
44
+ AdsConsentPurposes[AdsConsentPurposes["APPLY_MARKET_RESEARCH_TO_GENERATE_AUDIENCE_INSIGHTS"] = 9] = "APPLY_MARKET_RESEARCH_TO_GENERATE_AUDIENCE_INSIGHTS";
45
+ AdsConsentPurposes[AdsConsentPurposes["DEVELOP_AND_IMPROVE_PRODUCTS"] = 10] = "DEVELOP_AND_IMPROVE_PRODUCTS";
46
+ })(AdsConsentPurposes || (exports.AdsConsentPurposes = AdsConsentPurposes = {}));
47
+ //# sourceMappingURL=AdsConsentPurposes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AdsConsentPurposes.ts"],"names":["AdsConsentPurposes"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAEYA,kB;;;WAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;AAAAA,EAAAA,kB,CAAAA,kB;GAAAA,kB,kCAAAA,kB","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 * The definitions in this document are copied from IAB's global vendor list.\n *\n * https://vendor-list.consensu.org/v2/vendor-list.json\n * https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework\n *\n */\n\nexport enum AdsConsentPurposes {\n /**\n * Cookies, device identifiers, or other information can be stored or\n * accessed on your device for the purposes presented to you.\n *\n * Vendors can:\n * - Store and access information on the device such as cookies\n * and device identifiers presented to a user.\n */\n STORE_AND_ACCESS_INFORMATION_ON_DEVICE = 1,\n\n /**\n * Ads can be shown to you based on the content you’re viewing,\n * the app you’re using, your approximate location, or your device type.\n *\n * To do basic ad selection vendors can:\n * - Use real-time information about the context in which the ad will be shown,\n * to show the ad, including information about the content and the device, such as:\n * device type and capabilities, user agent, URL, IP address\n * - Use a user’s non-precise geolocation data\n * - Control the frequency of ads shown to a user.\n * - Sequence the order in which ads are shown to a user.\n * - Prevent an ad from serving in an unsuitable editorial (brand-unsafe) context\n *\n * Vendors cannot:\n * - Create a personalised ads profile using this information for the selection of\n * future ads without a separate legal basis to create a personalised ads profile.\n * - N.B. Non-precise means only an approximate location involving at least a radius\n * of 500 meters is permitted.\n */\n SELECT_BASIC_ADS = 2,\n\n /**\n * A profile can be built about you and your interests to show you personalised ads\n * that are relevant to you.\n *\n * To create a personalised ads profile vendors can:\n * - Collect information about a user, including a user's activity, interests,\n * demographic information, or location, to create or edit a user profile for use\n * in personalised advertising.\n * - Combine this information with other information previously collected,\n * including from across websites and apps, to create or edit a user profile\n * for use in personalised advertising.\n */\n CREATE_A_PERSONALISED_ADS_PROFILE = 3,\n\n /**\n * Personalised ads can be shown to you based on a profile about you.\n *\n * To select personalised ads vendors can:\n * - Select personalised ads based on a user profile or other historical user data,\n * including a user’s prior activity, interests, visits to sites or apps, location,\n * or demographic information.\n */\n SELECT_PERSONALISED_ADS = 4,\n\n /**\n * A profile can be built about you and your interests to show you personalised content\n * that is relevant to you.\n *\n * To create a personalised content profile vendors can:\n * - Collect information about a user, including a user's activity, interests, visits to\n * sites or apps, demographic information, or location, to create or edit a user profile\n * for personalising content.\n * - Combine this information with other information previously collected,\n * including from across websites and apps, to create or edit a user profile for use\n * in personalising content.\n */\n CREATE_A_PERSONALISED_CONTENT_PROFILE = 5,\n\n /**\n * Personalised content can be shown to you based on a profile about you.\n *\n * To select personalised content vendors can:\n * - Select personalised content based on a user profile or other historical user data,\n * including a user’s prior activity, interests, visits to sites or apps, location,\n * or demographic information.\n */\n SELECT_PERSONALISED_CONTENT = 6,\n\n /**\n * The performance and effectiveness of ads that you see or interact with can be measured.\n *\n * To measure ad performance vendors can:\n * - Measure whether and how ads were delivered to and interacted with by a user\n * - Provide reporting about ads including their effectiveness and performance\n * - Provide reporting about users who interacted with ads using data observed during\n * the course of the user's interaction with that ad\n * - Provide reporting to publishers about the ads displayed on their property\n * - Measure whether an ad is serving in a suitable editorial environment (brand-safe) context\n * - Determine the percentage of the ad that had the opportunity to be seen and\n * the duration of that opportunity\n * - Combine this information with other information previously collected,\n * including from across websites and apps\n *\n * Vendors cannot:\n * - Apply panel- or similarly-derived audience insights data to ad measurement data\n * without a Legal Basis to apply market research to generate audience insights (Purpose 9)\n */\n MEASURE_AD_PERFORMANCE = 7,\n\n /**\n * The performance and effectiveness of content that you see or interact with can be measured.\n *\n * To measure content performance vendors can:\n * - Measure and report on how content was delivered to and interacted with by users.\n * - Provide reporting, using directly measurable or known information, about users who\n * interacted with the content\n * - Combine this information with other information previously collected,\n * including from across websites and apps.\n *\n * Vendors cannot:\n * - Measure whether and how ads (including native ads) were delivered to and\n * interacted with by a user.\n * - Apply panel- or similarly derived audience insights data to ad measurement\n * data without a Legal Basis to apply market research to generate audience insights (Purpose 9)\n */\n MEASURE_CONTENT_PERFORMANCE = 8,\n\n /**\n * Market research can be used to learn more about the audiences who visit sites/apps and view ads.\n *\n * To apply market research to generate audience insights vendors can:\n * - Provide aggregate reporting to advertisers or their representatives about\n * the audiences reached by their ads, through panel-based and similarly derived insights.\n * - Provide aggregate reporting to publishers about the audiences that were served or\n * interacted with content and/or ads on their property by applying\n * panel-based and similarly derived insights.\n * - Associate offline data with an online user for the purposes of\n * market research to generate audience insights if vendors have declared to match and\n * combine offline data sources (Feature 1)\n * - Combine this information with other information previously collected including from\n * across websites and apps.\n *\n * Vendors cannot:\n * - Measure the performance and effectiveness of ads that a specific user was served or\n * interacted with, without a Legal Basis to measure ad performance.\n * - Measure which content a specific user was served and how they interacted with it,\n * without a Legal Basis to measure content performance.\n */\n APPLY_MARKET_RESEARCH_TO_GENERATE_AUDIENCE_INSIGHTS = 9,\n\n /**\n * Your data can be used to improve existing systems and software,\n * and to develop new products\n *\n * To develop new products and improve products vendors can:\n * - Use information to improve their existing products with new features and\n * to develop new products\n * - Create new models and algorithms through machine learning\n *\n * Vendors cannot:\n * - Conduct any other data processing operation allowed under\n * a different purpose under this purpose\n */\n DEVELOP_AND_IMPROVE_PRODUCTS = 10,\n}\n"]}