react-native-google-mobile-ads 4.2.0 → 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 (83) hide show
  1. package/RNGoogleMobileAds.podspec +16 -9
  2. package/__tests__/consent.test.ts +17 -9
  3. package/android/build.gradle +4 -3
  4. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsConsentModule.java +111 -168
  5. package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsModule.java +1 -1
  6. package/docs/common-reasons-for-ads-not-showing.mdx +26 -24
  7. package/docs/displaying-ads-hook.mdx +99 -0
  8. package/docs/displaying-ads.mdx +3 -4
  9. package/docs/european-user-consent.mdx +67 -156
  10. package/docs/index.mdx +16 -16
  11. package/docs/migrating-to-v5.mdx +63 -0
  12. package/docs.json +4 -2
  13. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.h +0 -1
  14. package/ios/RNGoogleMobileAds/RNGoogleMobileAdsConsentModule.m +83 -124
  15. package/ios_config.sh +8 -0
  16. package/lib/commonjs/AdsConsent.js +58 -98
  17. package/lib/commonjs/AdsConsent.js.map +1 -1
  18. package/lib/commonjs/AdsConsentPurposes.js +47 -0
  19. package/lib/commonjs/AdsConsentPurposes.js.map +1 -0
  20. package/lib/commonjs/AdsConsentSpecialFeatures.js +39 -0
  21. package/lib/commonjs/AdsConsentSpecialFeatures.js.map +1 -0
  22. package/lib/commonjs/AdsConsentStatus.js +4 -3
  23. package/lib/commonjs/AdsConsentStatus.js.map +1 -1
  24. package/lib/commonjs/hooks/useAppOpenAd.js +51 -0
  25. package/lib/commonjs/hooks/useAppOpenAd.js.map +1 -0
  26. package/lib/commonjs/hooks/useFullScreenAd.js +120 -0
  27. package/lib/commonjs/hooks/useFullScreenAd.js.map +1 -0
  28. package/lib/commonjs/hooks/useInterstitialAd.js +51 -0
  29. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
  30. package/lib/commonjs/hooks/useRewardedAd.js +51 -0
  31. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
  32. package/lib/commonjs/index.js +40 -0
  33. package/lib/commonjs/index.js.map +1 -1
  34. package/lib/commonjs/types/AdStates.js +6 -0
  35. package/lib/commonjs/types/AdStates.js.map +1 -0
  36. package/lib/commonjs/version.js +1 -1
  37. package/lib/commonjs/version.js.map +1 -1
  38. package/lib/module/AdsConsent.js +56 -98
  39. package/lib/module/AdsConsent.js.map +1 -1
  40. package/lib/module/AdsConsentPurposes.js +39 -0
  41. package/lib/module/AdsConsentPurposes.js.map +1 -0
  42. package/lib/module/AdsConsentSpecialFeatures.js +31 -0
  43. package/lib/module/AdsConsentSpecialFeatures.js.map +1 -0
  44. package/lib/module/AdsConsentStatus.js +4 -3
  45. package/lib/module/AdsConsentStatus.js.map +1 -1
  46. package/lib/module/hooks/useAppOpenAd.js +38 -0
  47. package/lib/module/hooks/useAppOpenAd.js.map +1 -0
  48. package/lib/module/hooks/useFullScreenAd.js +109 -0
  49. package/lib/module/hooks/useFullScreenAd.js.map +1 -0
  50. package/lib/module/hooks/useInterstitialAd.js +38 -0
  51. package/lib/module/hooks/useInterstitialAd.js.map +1 -0
  52. package/lib/module/hooks/useRewardedAd.js +38 -0
  53. package/lib/module/hooks/useRewardedAd.js.map +1 -0
  54. package/lib/module/index.js +5 -0
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/types/AdStates.js +2 -0
  57. package/lib/module/types/AdStates.js.map +1 -0
  58. package/lib/module/version.js +1 -1
  59. package/lib/module/version.js.map +1 -1
  60. package/lib/typescript/AdsConsentPurposes.d.ts +148 -0
  61. package/lib/typescript/AdsConsentSpecialFeatures.d.ts +22 -0
  62. package/lib/typescript/AdsConsentStatus.d.ts +10 -6
  63. package/lib/typescript/hooks/useAppOpenAd.d.ts +9 -0
  64. package/lib/typescript/hooks/useFullScreenAd.d.ts +5 -0
  65. package/lib/typescript/hooks/useInterstitialAd.d.ts +9 -0
  66. package/lib/typescript/hooks/useRewardedAd.d.ts +9 -0
  67. package/lib/typescript/index.d.ts +6 -1
  68. package/lib/typescript/types/AdStates.d.ts +85 -0
  69. package/lib/typescript/types/AdsConsent.interface.d.ts +229 -180
  70. package/lib/typescript/version.d.ts +1 -1
  71. package/package.json +10 -4
  72. package/src/AdsConsent.ts +91 -135
  73. package/src/AdsConsentPurposes.ts +182 -0
  74. package/src/AdsConsentSpecialFeatures.ts +48 -0
  75. package/src/AdsConsentStatus.ts +11 -6
  76. package/src/hooks/useAppOpenAd.ts +46 -0
  77. package/src/hooks/useFullScreenAd.ts +104 -0
  78. package/src/hooks/useInterstitialAd.ts +46 -0
  79. package/src/hooks/useRewardedAd.ts +46 -0
  80. package/src/index.ts +5 -0
  81. package/src/types/AdStates.ts +87 -0
  82. package/src/types/AdsConsent.interface.ts +230 -187
  83. package/src/version.ts +1 -1
@@ -18,6 +18,9 @@
18
18
 
19
19
  #import <React/RCTUtils.h>
20
20
 
21
+ #import <React/RCTConvert.h>
22
+ #include <UserMessagingPlatform/UserMessagingPlatform.h>
23
+ #import "RCTBridgeModule.h"
21
24
  #import "RNGoogleMobileAdsConsentModule.h"
22
25
  #import "common/RNSharedUtils.h"
23
26
 
@@ -34,146 +37,102 @@ RCT_EXPORT_MODULE();
34
37
  #pragma mark -
35
38
  #pragma mark Google Mobile Ads Methods
36
39
 
37
- RCT_EXPORT_METHOD(requestInfoUpdate
38
- : (NSArray *)publisherIds
39
- : (RCTPromiseResolveBlock)resolve
40
- : (RCTPromiseRejectBlock)reject) {
41
- PACConsentInformation *consentInformation = [PACConsentInformation sharedInstance];
42
-
43
- id completionHandler = ^(NSError *_Nullable error) {
44
- if (error != nil) {
45
- [RNSharedUtils rejectPromiseWithUserInfo:reject
46
- userInfo:[@{
47
- @"code" : @"consent-update-failed",
48
- @"message" : error.localizedDescription,
49
- } mutableCopy]];
50
- } else {
51
- resolve(@{
52
- @"status" : @(consentInformation.consentStatus),
53
- @"isRequestLocationInEeaOrUnknown" : @(consentInformation.requestLocationInEEAOrUnknown),
54
- });
55
- }
56
- };
57
-
58
- [consentInformation requestConsentInfoUpdateForPublisherIdentifiers:publisherIds
59
- completionHandler:completionHandler];
40
+ - (NSString *)getConsentStatusString:(UMPConsentStatus)consentStatus {
41
+ switch (consentStatus) {
42
+ case UMPConsentStatusRequired:
43
+ return @"REQUIRED";
44
+ case UMPConsentStatusNotRequired:
45
+ return @"NOT_REQUIRED";
46
+ case UMPConsentStatusObtained:
47
+ return @"OBTAINED";
48
+ case UMPConsentStatusUnknown:
49
+ default:
50
+ return @"UNKNOWN";
51
+ }
60
52
  }
61
53
 
62
- RCT_EXPORT_METHOD(showForm
54
+ RCT_EXPORT_METHOD(requestInfoUpdate
63
55
  : (NSDictionary *)options
64
56
  : (RCTPromiseResolveBlock)resolve
65
57
  : (RCTPromiseRejectBlock)reject) {
66
- NSString *privacyPolicy = options[@"privacyPolicy"];
67
- PACConsentForm *form = [[PACConsentForm alloc]
68
- initWithApplicationPrivacyPolicyURL:[NSURL URLWithString:privacyPolicy]];
69
-
70
- form.shouldOfferPersonalizedAds = [options[@"withPersonalizedAds"] boolValue];
71
- form.shouldOfferNonPersonalizedAds = [options[@"withNonPersonalizedAds"] boolValue];
72
- form.shouldOfferAdFree = [options[@"withAdFree"] boolValue];
73
-
74
- id dismissCompletionBlock = ^(NSError *error, BOOL userPrefersAdFree) {
75
- if (error != nil) {
76
- [RNSharedUtils rejectPromiseWithUserInfo:reject
77
- userInfo:[@{
78
- @"code" : @"consent-form-error",
79
- @"message" : error.localizedDescription,
80
- } mutableCopy]];
81
- } else {
82
- resolve(@{
83
- @"status" : @(PACConsentInformation.sharedInstance.consentStatus),
84
- @"userPrefersAdFree" : @(userPrefersAdFree),
85
- });
86
- }
87
- };
58
+ UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
59
+ UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
60
+
61
+ debugSettings.geography = [options[@"debugGeography"] integerValue] ?: UMPDebugGeographyDisabled;
62
+ debugSettings.testDeviceIdentifiers =
63
+ [options valueForKeyPath:@"testDeviceIdentifiers"] ?: [[NSMutableArray alloc] init];
64
+
65
+ parameters.debugSettings = debugSettings;
66
+ parameters.tagForUnderAgeOfConsent = [options[@"tagForUnderAgeOfConsent"] boolValue] ?: FALSE;
67
+
68
+ [UMPConsentInformation.sharedInstance
69
+ requestConsentInfoUpdateWithParameters:parameters
70
+ completionHandler:^(NSError *_Nullable error) {
71
+ if (error) {
72
+ [RNSharedUtils
73
+ rejectPromiseWithUserInfo:reject
74
+ userInfo:[@{
75
+ @"code" : @"consent-update-failed",
76
+ @"message" : error.localizedDescription,
77
+ } mutableCopy]];
78
+ } else {
79
+ resolve(@{
80
+ @"status" : [self
81
+ getConsentStatusString:UMPConsentInformation.sharedInstance
82
+ .consentStatus],
83
+ @"isConsentFormAvailable" :
84
+ @(UMPConsentInformation.sharedInstance.formStatus ==
85
+ UMPFormStatusAvailable)
86
+ });
87
+ }
88
+ }];
89
+ }
88
90
 
89
- [form loadWithCompletionHandler:^(NSError *error) {
90
- if (error != nil) {
91
+ RCT_EXPORT_METHOD(showForm : (RCTPromiseResolveBlock)resolve : (RCTPromiseRejectBlock)reject) {
92
+ [UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) {
93
+ if (loadError) {
91
94
  [RNSharedUtils rejectPromiseWithUserInfo:reject
92
95
  userInfo:[@{
93
96
  @"code" : @"consent-form-error",
94
- @"message" : error.localizedDescription,
97
+ @"message" : loadError.localizedDescription,
95
98
  } mutableCopy]];
96
99
  } else {
97
- [form presentFromViewController:[UIApplication sharedApplication]
98
- .delegate.window.rootViewController
99
- dismissCompletion:dismissCompletionBlock];
100
+ [form
101
+ presentFromViewController:[UIApplication sharedApplication]
102
+ .delegate.window.rootViewController
103
+ completionHandler:^(NSError *_Nullable dismissError) {
104
+ if (dismissError) {
105
+ [RNSharedUtils
106
+ rejectPromiseWithUserInfo:reject
107
+ userInfo:[@{
108
+ @"code" : @"consent-form-error",
109
+ @"message" : dismissError.localizedDescription,
110
+ } mutableCopy]];
111
+ } else {
112
+ resolve(@{
113
+ @"status" : [self getConsentStatusString:UMPConsentInformation
114
+ .sharedInstance.consentStatus],
115
+ });
116
+ }
117
+ }];
100
118
  }
101
119
  }];
102
120
  }
103
121
 
104
- RCT_EXPORT_METHOD(getStatus : (RCTPromiseResolveBlock)resolve : (RCTPromiseRejectBlock)reject) {
105
- PACConsentInformation *consentInformation = [PACConsentInformation sharedInstance];
106
- resolve(@(consentInformation.consentStatus));
107
- }
108
-
109
- RCT_EXPORT_METHOD(setStatus
110
- : (nonnull NSNumber *)status
111
- : (RCTPromiseResolveBlock)resolve
112
- : (RCTPromiseRejectBlock)reject) {
113
- PACConsentStatus consentStatus = PACConsentStatusUnknown;
114
-
115
- if ([status integerValue] == [@0 integerValue]) {
116
- consentStatus = PACConsentStatusUnknown;
117
- } else if ([status integerValue] == [@1 integerValue]) {
118
- consentStatus = PACConsentStatusNonPersonalized;
119
- } else if ([status integerValue] == [@2 integerValue]) {
120
- consentStatus = PACConsentStatusPersonalized;
121
- }
122
-
123
- PACConsentInformation.sharedInstance.consentStatus = consentStatus;
124
- resolve([NSNull null]);
125
- }
126
-
127
- RCT_EXPORT_METHOD(getAdProviders
128
- : (RCTPromiseResolveBlock)resolve
129
- : (RCTPromiseRejectBlock)reject) {
130
- NSArray *providers = PACConsentInformation.sharedInstance.adProviders;
131
- NSMutableArray *formattedProviders = [[NSMutableArray alloc] init];
132
-
133
- for (PACAdProvider *provider in providers) {
134
- NSMutableDictionary *formattedProvider = [[NSMutableDictionary alloc] init];
135
- formattedProvider[@"companyName"] = provider.name;
136
- formattedProvider[@"companyId"] = [provider.identifier stringValue];
137
- formattedProvider[@"privacyPolicyUrl"] = provider.privacyPolicyURL.absoluteString;
138
- [formattedProviders addObject:formattedProvider];
139
- }
140
-
141
- resolve(formattedProviders);
142
- }
143
-
144
- RCT_EXPORT_METHOD(setTagForUnderAgeOfConsent
145
- : (BOOL)tag
146
- : (RCTPromiseResolveBlock)resolve
147
- : (RCTPromiseRejectBlock)reject) {
148
- PACConsentInformation *consentInformation = [PACConsentInformation sharedInstance];
149
- consentInformation.tagForUnderAgeOfConsent = tag;
150
- resolve([NSNull null]);
151
- }
152
-
153
- RCT_EXPORT_METHOD(setDebugGeography
154
- : (nonnull NSNumber *)geography
155
- : (RCTPromiseResolveBlock)resolve
156
- : (RCTPromiseRejectBlock)reject) {
157
- PACDebugGeography debugGeography = PACDebugGeographyDisabled;
158
-
159
- if ([geography integerValue] == [@0 integerValue]) {
160
- debugGeography = PACDebugGeographyDisabled;
161
- } else if ([geography integerValue] == [@1 integerValue]) {
162
- debugGeography = PACDebugGeographyEEA;
163
- } else if ([geography integerValue] == [@2 integerValue]) {
164
- debugGeography = PACDebugGeographyNotEEA;
122
+ RCT_EXPORT_METHOD(reset) { [UMPConsentInformation.sharedInstance reset]; }
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]];
165
135
  }
166
-
167
- PACConsentInformation.sharedInstance.debugGeography = debugGeography;
168
- resolve([NSNull null]);
169
- }
170
-
171
- RCT_EXPORT_METHOD(addTestDevices
172
- : (NSArray *)deviceIds
173
- : (RCTPromiseResolveBlock)resolve
174
- : (RCTPromiseRejectBlock)reject) {
175
- PACConsentInformation.sharedInstance.debugIdentifiers = deviceIds;
176
- resolve([NSNull null]);
177
136
  }
178
137
 
179
138
  @end
package/ios_config.sh CHANGED
@@ -102,6 +102,14 @@ if [[ ${_SEARCH_RESULT} ]]; then
102
102
  _PLIST_ENTRY_TYPES+=("string")
103
103
  _PLIST_ENTRY_VALUES+=("$_IOS_APP_ID")
104
104
  fi
105
+
106
+ # config.user_tracking_usage_description
107
+ _USER_TRACKING_USAGE_DESCRIPTION=$(getJsonKeyValue "$_JSON_OUTPUT_RAW" "user_tracking_usage_description")
108
+ if [[ $_USER_TRACKING_USAGE_DESCRIPTION ]]; then
109
+ _PLIST_ENTRY_KEYS+=("NSUserTrackingUsageDescription")
110
+ _PLIST_ENTRY_TYPES+=("string")
111
+ _PLIST_ENTRY_VALUES+=("$_USER_TRACKING_USAGE_DESCRIPTION")
112
+ fi
105
113
  else
106
114
  _PLIST_ENTRY_KEYS+=("google_mobile_ads_json_raw")
107
115
  _PLIST_ENTRY_TYPES+=("string")
@@ -5,13 +5,17 @@ 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 _AdsConsentStatus = require("./AdsConsentStatus");
14
+ var _AdsConsentPurposes = require("./AdsConsentPurposes");
15
+
16
+ var _AdsConsentSpecialFeatures = require("./AdsConsentSpecialFeatures");
17
+
18
+ var _common = require("./common");
15
19
 
16
20
  /*
17
21
  * Copyright (c) 2016-present Invertase Limited & Contributors
@@ -31,128 +35,84 @@ var _AdsConsentStatus = require("./AdsConsentStatus");
31
35
  */
32
36
  const native = _reactNative.NativeModules.RNGoogleMobileAdsConsentModule;
33
37
  const AdsConsent = {
34
- /**
35
- *
36
- * @param publisherIds
37
- * @returns {*}
38
- */
39
- requestInfoUpdate(publisherIds) {
40
- if (!(0, _common.isArray)(publisherIds)) {
41
- throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.");
42
- }
43
-
44
- if (publisherIds.length === 0) {
45
- throw new Error("AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.");
46
- }
47
-
48
- for (let i = 0; i < publisherIds.length; i++) {
49
- if (!(0, _common.isString)(publisherIds[i])) {
50
- throw new Error(`AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`);
51
- }
52
- }
53
-
54
- return native.requestInfoUpdate(publisherIds);
55
- },
38
+ requestInfoUpdate() {
39
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
56
40
 
57
- /**
58
- *
59
- * @param options
60
- * @returns {*}
61
- */
62
- showForm(options) {
63
- if (!(0, _common.isUndefined)(options) && !(0, _common.isObject)(options)) {
64
- throw new Error("AdsConsent.showForm(*) 'options' expected an object value.");
41
+ if (!(0, _common.isObject)(options)) {
42
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options' expected an object value.");
65
43
  }
66
44
 
67
- if (!(0, _common.isValidUrl)(options.privacyPolicy)) {
68
- throw new Error("AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.");
45
+ if ((0, _common.hasOwnProperty)(options, 'debugGeography') && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.DISABLED && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.EEA && options.debugGeography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.NOT_EEA) {
46
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options.debugGeography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.");
69
47
  }
70
48
 
71
- if ((0, _common.hasOwnProperty)(options, 'withPersonalizedAds') && !(0, _common.isBoolean)(options.withPersonalizedAds)) {
72
- throw new Error("AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.");
49
+ if ((0, _common.hasOwnProperty)(options, 'tagForUnderAgeOfConsent') && !(0, _common.isBoolean)(options.tagForUnderAgeOfConsent)) {
50
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options.tagForUnderAgeOfConsent' expected a boolean value.");
73
51
  }
74
52
 
75
- if ((0, _common.hasOwnProperty)(options, 'withNonPersonalizedAds') && !(0, _common.isBoolean)(options.withNonPersonalizedAds)) {
76
- throw new Error("AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value.");
77
- }
53
+ if ((0, _common.hasOwnProperty)(options, 'testDeviceIdentifiers')) {
54
+ if (!(0, _common.isArray)(options.testDeviceIdentifiers)) {
55
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.");
56
+ }
78
57
 
79
- if ((0, _common.hasOwnProperty)(options, 'withAdFree') && !(0, _common.isBoolean)(options.withAdFree)) {
80
- throw new Error("AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value.");
81
- }
58
+ for (const deviceId of (_options$testDeviceId = options.testDeviceIdentifiers) !== null && _options$testDeviceId !== void 0 ? _options$testDeviceId : []) {
59
+ var _options$testDeviceId;
82
60
 
83
- if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) {
84
- throw new Error("AdsConsent.showForm(*) 'options' form requires at least one option to be enabled.");
61
+ if (!(0, _common.isString)(deviceId)) {
62
+ throw new Error("AdsConsent.requestInfoUpdate(*) 'options.testDeviceIdentifiers' expected an array of string values.");
63
+ }
64
+ }
85
65
  }
86
66
 
87
- return native.showForm(options);
67
+ return native.requestInfoUpdate(options);
88
68
  },
89
69
 
90
- /**
91
- *
92
- */
93
- getAdProviders() {
94
- return native.getAdProviders();
70
+ showForm() {
71
+ return native.showForm();
95
72
  },
96
73
 
97
- /**
98
- *
99
- * @param geography
100
- */
101
- setDebugGeography(geography) {
102
- if (geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.DISABLED && geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.EEA && geography !== _AdsConsentDebugGeography.AdsConsentDebugGeography.NOT_EEA) {
103
- throw new Error("AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.");
104
- }
105
-
106
- return native.setDebugGeography(geography);
74
+ reset() {
75
+ return native.reset();
107
76
  },
108
77
 
109
- /**
110
- *
111
- */
112
- getStatus() {
113
- return native.getStatus();
78
+ getTCString() {
79
+ return native.getTCString();
114
80
  },
115
81
 
116
- /**
117
- *
118
- * @param status
119
- */
120
- setStatus(status) {
121
- if (status !== _AdsConsentStatus.AdsConsentStatus.UNKNOWN && status !== _AdsConsentStatus.AdsConsentStatus.NON_PERSONALIZED && status !== _AdsConsentStatus.AdsConsentStatus.PERSONALIZED) {
122
- throw new Error("AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED.");
123
- }
124
-
125
- return native.setStatus(status);
82
+ async getTCModel() {
83
+ const tcString = await native.getTCString();
84
+ return _core.TCString.decode(tcString);
126
85
  },
127
86
 
128
- /**
129
- *
130
- * @param tag
131
- */
132
- setTagForUnderAgeOfConsent(tag) {
133
- if (!(0, _common.isBoolean)(tag)) {
134
- throw new Error("AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value.");
135
- }
136
-
137
- return native.setTagForUnderAgeOfConsent(tag);
138
- },
87
+ async getUserChoices() {
88
+ const tcString = await native.getTCString();
89
+ let tcModel;
139
90
 
140
- /**
141
- *
142
- * @param deviceIds
143
- */
144
- addTestDevices(deviceIds) {
145
- if (!(0, _common.isArray)(deviceIds)) {
146
- throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.");
147
- }
91
+ try {
92
+ tcModel = _core.TCString.decode(tcString);
93
+ } catch (e) {
94
+ tcModel = new _core.TCModel();
148
95
 
149
- for (let i = 0; i < deviceIds.length; i++) {
150
- if (!(0, _common.isString)(deviceIds[i])) {
151
- throw new Error("AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.");
96
+ if (__DEV__) {
97
+ // eslint-disable-next-line no-console
98
+ console.warn(`Failed to decode tcString ${tcString}:`, e);
152
99
  }
153
100
  }
154
101
 
155
- return native.addTestDevices(deviceIds);
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
+ };
156
116
  }
157
117
 
158
118
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["AdsConsent.ts"],"names":["native","NativeModules","RNGoogleMobileAdsConsentModule","AdsConsent","requestInfoUpdate","publisherIds","Error","length","i","showForm","options","privacyPolicy","withPersonalizedAds","withNonPersonalizedAds","withAdFree","getAdProviders","setDebugGeography","geography","AdsConsentDebugGeography","DISABLED","EEA","NOT_EEA","getStatus","setStatus","status","AdsConsentStatus","UNKNOWN","NON_PERSONALIZED","PERSONALIZED","setTagForUnderAgeOfConsent","tag","addTestDevices","deviceIds"],"mappings":";;;;;;;AAiBA;;AASA;;AACA;;AACA;;AA5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAgBA,MAAMA,MAAM,GAAGC,2BAAcC,8BAA7B;AAEO,MAAMC,UAA+B,GAAG;AAC7C;AACF;AACA;AACA;AACA;AACEC,EAAAA,iBAAiB,CAACC,YAAD,EAAe;AAC9B,QAAI,CAAC,qBAAQA,YAAR,CAAL,EAA4B;AAC1B,YAAM,IAAIC,KAAJ,CACJ,oFADI,CAAN;AAGD;;AAED,QAAID,YAAY,CAACE,MAAb,KAAwB,CAA5B,EAA+B;AAC7B,YAAM,IAAID,KAAJ,CACJ,uFADI,CAAN;AAGD;;AAED,SAAK,IAAIE,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGH,YAAY,CAACE,MAAjC,EAAyCC,CAAC,EAA1C,EAA8C;AAC5C,UAAI,CAAC,sBAASH,YAAY,CAACG,CAAD,CAArB,CAAL,EAAgC;AAC9B,cAAM,IAAIF,KAAJ,CACH,iDAAgDE,CAAE,6BAD/C,CAAN;AAGD;AACF;;AAED,WAAOR,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CAAC+B,cAAP,CAAsBC,SAAtB,CAAP;AACD;;AA5J4C,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 {\n hasOwnProperty,\n isArray,\n isBoolean,\n isObject,\n isString,\n isUndefined,\n isValidUrl,\n} from './common';\nimport { NativeModules } from 'react-native';\nimport { AdsConsentDebugGeography } from './AdsConsentDebugGeography';\nimport { AdsConsentStatus } from './AdsConsentStatus';\nimport { AdsConsentInterface } from './types/AdsConsent.interface';\n\nconst native = NativeModules.RNGoogleMobileAdsConsentModule;\n\nexport const AdsConsent: AdsConsentInterface = {\n /**\n *\n * @param publisherIds\n * @returns {*}\n */\n requestInfoUpdate(publisherIds) {\n if (!isArray(publisherIds)) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.\",\n );\n }\n\n if (publisherIds.length === 0) {\n throw new Error(\n \"AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.\",\n );\n }\n\n for (let i = 0; i < publisherIds.length; i++) {\n if (!isString(publisherIds[i])) {\n throw new Error(\n `AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`,\n );\n }\n }\n\n return native.requestInfoUpdate(publisherIds);\n },\n\n /**\n *\n * @param options\n * @returns {*}\n */\n showForm(options) {\n if (!isUndefined(options) && !isObject(options)) {\n throw new Error(\"AdsConsent.showForm(*) 'options' expected an object value.\");\n }\n\n if (!isValidUrl(options.privacyPolicy)) {\n throw new Error(\n \"AdsConsent.showForm(*) 'options.privacyPolicy' expected a valid HTTP or HTTPS URL.\",\n );\n }\n\n if (hasOwnProperty(options, 'withPersonalizedAds') && !isBoolean(options.withPersonalizedAds)) {\n throw new Error(\n \"AdsConsent.showForm(*) 'options.withPersonalizedAds' expected a boolean value.\",\n );\n }\n\n if (\n hasOwnProperty(options, 'withNonPersonalizedAds') &&\n !isBoolean(options.withNonPersonalizedAds)\n ) {\n throw new Error(\n \"AdsConsent.showForm(*) 'options.withNonPersonalizedAds' expected a boolean value.\",\n );\n }\n\n if (hasOwnProperty(options, 'withAdFree') && !isBoolean(options.withAdFree)) {\n throw new Error(\"AdsConsent.showForm(*) 'options.withAdFree' expected a boolean value.\");\n }\n\n if (!options.withPersonalizedAds && !options.withNonPersonalizedAds && !options.withAdFree) {\n throw new Error(\n \"AdsConsent.showForm(*) 'options' form requires at least one option to be enabled.\",\n );\n }\n\n return native.showForm(options);\n },\n\n /**\n *\n */\n getAdProviders() {\n return native.getAdProviders();\n },\n\n /**\n *\n * @param geography\n */\n setDebugGeography(geography) {\n if (\n geography !== AdsConsentDebugGeography.DISABLED &&\n geography !== AdsConsentDebugGeography.EEA &&\n geography !== AdsConsentDebugGeography.NOT_EEA\n ) {\n throw new Error(\n \"AdsConsent.setDebugGeography(*) 'geography' expected one of AdsConsentDebugGeography.DISABLED, AdsConsentDebugGeography.EEA or AdsConsentDebugGeography.NOT_EEA.\",\n );\n }\n\n return native.setDebugGeography(geography);\n },\n\n /**\n *\n */\n getStatus() {\n return native.getStatus();\n },\n\n /**\n *\n * @param status\n */\n setStatus(status) {\n if (\n status !== AdsConsentStatus.UNKNOWN &&\n status !== AdsConsentStatus.NON_PERSONALIZED &&\n status !== AdsConsentStatus.PERSONALIZED\n ) {\n throw new Error(\n \"AdsConsent.setStatus(*) 'status' expected one of AdsConsentStatus.UNKNOWN, AdsConsentStatus.NON_PERSONALIZED or AdsConsentStatus.PERSONALIZED.\",\n );\n }\n\n return native.setStatus(status);\n },\n\n /**\n *\n * @param tag\n */\n setTagForUnderAgeOfConsent(tag) {\n if (!isBoolean(tag)) {\n throw new Error(\"AdsConsent.setTagForUnderAgeOfConsent(*) 'tag' expected a boolean value.\");\n }\n\n return native.setTagForUnderAgeOfConsent(tag);\n },\n\n /**\n *\n * @param deviceIds\n */\n addTestDevices(deviceIds) {\n if (!isArray(deviceIds)) {\n throw new Error(\n \"AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.\",\n );\n }\n\n for (let i = 0; i < deviceIds.length; i++) {\n if (!isString(deviceIds[i])) {\n throw new Error(\n \"AdsConsent.addTestDevices(*) 'deviceIds' expected an array of string values.\",\n );\n }\n }\n\n return native.addTestDevices(deviceIds);\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_GEOLOC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4BADM,CAbtB;AAgBLC,MAAAA,oBAAoB,EAAEpB,OAAO,CAACY,eAAR,CAAwBJ,GAAxB,CAA4BK,uCAAmBQ,sBAA/C,CAhBjB;AAiBLC,MAAAA,yBAAyB,EAAEtB,OAAO,CAACY,eAAR,CAAwBJ,GAAxB,CACzBK,uCAAmBU,2BADM,CAjBtB;AAoBLC,MAAAA,cAAc,EAAExB,OAAO,CAACY,eAAR,CAAwBJ,GAAxB,CAA4BK,uCAAmBY,gBAA/C,CApBX;AAqBLC,MAAAA,qBAAqB,EAAE1B,OAAO,CAACY,eAAR,CAAwBJ,GAAxB,CACrBK,uCAAmBc,uBADE,CArBlB;AAwBLC,MAAAA,yBAAyB,EAAE5B,OAAO,CAACY,eAAR,CAAwBJ,GAAxB,CACzBK,uCAAmBgB,2BADM,CAxBtB;AA2BLC,MAAAA,iCAAiC,EAAE9B,OAAO,CAACY,eAAR,CAAwBJ,GAAxB,CACjCK,uCAAmBkB,sCADc,CA3B9B;AA8BLC,MAAAA,yBAAyB,EAAEhC,OAAO,CAACO,oBAAR,CAA6BC,GAA7B,CACzBC,qDAA0BwB,4BADD;AA9BtB,KAAP;AAkCD;;AAhH4C,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 { 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"]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AdsConsentSpecialFeatures = 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 AdsConsentSpecialFeatures;
33
+ exports.AdsConsentSpecialFeatures = AdsConsentSpecialFeatures;
34
+
35
+ (function (AdsConsentSpecialFeatures) {
36
+ AdsConsentSpecialFeatures[AdsConsentSpecialFeatures["USE_PRECISE_GEOLOCATION_DATA"] = 1] = "USE_PRECISE_GEOLOCATION_DATA";
37
+ AdsConsentSpecialFeatures[AdsConsentSpecialFeatures["ACTIVELY_SCAN_DEVICE_CHARACTERISTICS_FOR_IDENTIFICATION"] = 2] = "ACTIVELY_SCAN_DEVICE_CHARACTERISTICS_FOR_IDENTIFICATION";
38
+ })(AdsConsentSpecialFeatures || (exports.AdsConsentSpecialFeatures = AdsConsentSpecialFeatures = {}));
39
+ //# sourceMappingURL=AdsConsentSpecialFeatures.js.map