cordova-plugin-admob-nextgen 2.0.0 → 2.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -11
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/src/android/ConsentExecutor.java +31 -16
- package/src/ios/ConsentExecutor.m +25 -16
- package/www/admob-nextgen.js +2 -0
package/README.md
CHANGED
|
@@ -115,7 +115,7 @@ This plugin is regularly updated to support the latest standards.
|
|
|
115
115
|
|
|
116
116
|
| Component | Platform | Version | Release Notes |
|
|
117
117
|
| :--- | :--- | :--- | :--- |
|
|
118
|
-
| **GMA Next-Gen SDK** | Android | **1.
|
|
118
|
+
| **GMA Next-Gen SDK** | Android | **1.3.0** | [View Notes](https://developers.google.com/admob/android/next-gen/rel-notes) |
|
|
119
119
|
| **UMP SDK** | Android | **4.0.0** | [View Notes](https://developers.google.com/admob/android/privacy/release-notes) |
|
|
120
120
|
| **Mobile Ads SDK** | iOS | **13.3.0** | [View Notes](https://developers.google.com/admob/ios/rel-notes) |
|
|
121
121
|
| **UMP SDK** | iOS | **3.1.0** | [View Notes](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download) |
|
|
@@ -289,7 +289,10 @@ admobNextGen.getTCData(function(tcData) {
|
|
|
289
289
|
```
|
|
290
290
|
|
|
291
291
|
#### B: Advanced Usage (Raw Data Control)
|
|
292
|
-
|
|
292
|
+
|
|
293
|
+
Advanced users who want full control over the consent logic can completely ignore the built-in boolean flags. The plugin now dynamically extracts and exposes **ALL standard IAB TCF v2 keys** directly from the device's local storage.
|
|
294
|
+
|
|
295
|
+
This means you have full access to every `IABTCF_` prefixed key (such as `IABTCF_PurposeConsents`, `IABTCF_VendorLegitimateInterests`, `IABTCF_SpecialFeaturesOptIns`, etc.), allowing you to manipulate and build custom enum conditions based on your own specific architecture requirements.
|
|
293
296
|
|
|
294
297
|
```javascript
|
|
295
298
|
admobNextGen.getTCData(function(tcData) {
|
|
@@ -298,21 +301,24 @@ admobNextGen.getTCData(function(tcData) {
|
|
|
298
301
|
// Note: IAB TCF strings are 1-indexed, but JavaScript strings are 0-indexed.
|
|
299
302
|
// Index 0 represents Purpose 1, Index 2 represents Purpose 3, etc.
|
|
300
303
|
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
// You can use the standard IABTCF_ keys extracted dynamically by the plugin
|
|
305
|
+
const purposes = tcData.IABTCF_PurposeConsents || "";
|
|
306
|
+
const lis = tcData.IABTCF_PurposeLegitimateInterests || "";
|
|
307
|
+
const vendors = tcData.IABTCF_VendorConsents || "";
|
|
308
|
+
const vendorLIs = tcData.IABTCF_VendorLegitimateInterests || "";
|
|
309
|
+
|
|
310
|
+
// const tcs = tcData.IABTCF_TCString;
|
|
311
|
+
// const region = tcData.IABTCF_gdprApplies;
|
|
307
312
|
|
|
308
313
|
// Custom logic example: Check if Purpose 1 and Purpose 3 are explicitly granted
|
|
309
314
|
const hasPurpose1 = purposes.charAt(0) === '1';
|
|
310
315
|
const hasPurpose3 = purposes.charAt(2) === '1';
|
|
311
316
|
|
|
312
|
-
// Check if Vendor 755 (Google) is granted (Index 754)
|
|
313
|
-
const
|
|
317
|
+
// Check if Vendor 755 (Google) Consent OR Legitimate Interest is granted (Index 754)
|
|
318
|
+
const hasGoogleVendorConsent = vendors.charAt(754) === '1';
|
|
319
|
+
const hasGoogleVendorLI = vendorLIs.charAt(754) === '1';
|
|
314
320
|
|
|
315
|
-
if (hasPurpose1 && hasPurpose3 &&
|
|
321
|
+
if (hasPurpose1 && hasPurpose3 && (hasGoogleVendorConsent || hasGoogleVendorLI)) {
|
|
316
322
|
console.log("Custom advanced condition met!");
|
|
317
323
|
// Your custom ad loading logic here
|
|
318
324
|
} else {
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
2
|
<plugin id="cordova-plugin-admob-nextgen"
|
|
3
|
-
version="2.0.
|
|
3
|
+
version="2.0.1-beta.1"
|
|
4
4
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
5
5
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
6
6
|
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
|
|
54
54
|
</platform>
|
|
55
55
|
|
|
56
|
-
<preference name="NEXT_GEN_SDK_VERSION" default="1.
|
|
56
|
+
<preference name="NEXT_GEN_SDK_VERSION" default="1.3.0" />
|
|
57
57
|
<preference name="UMP_VERSION" default="4.0.0" />
|
|
58
58
|
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
|
|
59
59
|
<preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
|
|
@@ -18,6 +18,7 @@ import org.json.JSONObject;
|
|
|
18
18
|
import java.security.MessageDigest;
|
|
19
19
|
import java.security.NoSuchAlgorithmException;
|
|
20
20
|
import java.util.Locale;
|
|
21
|
+
import java.util.Map;
|
|
21
22
|
|
|
22
23
|
import com.google.android.ump.ConsentDebugSettings;
|
|
23
24
|
import com.google.android.ump.ConsentInformation;
|
|
@@ -47,6 +48,7 @@ public class ConsentExecutor {
|
|
|
47
48
|
boolean resetConsent = false;
|
|
48
49
|
boolean tagForUnderAgeOfConsent = false;
|
|
49
50
|
|
|
51
|
+
boolean tempShowFormIfRequired = true;
|
|
50
52
|
if (options != null) {
|
|
51
53
|
debugMode = options.optBoolean("debug", false);
|
|
52
54
|
manualTestDeviceId = options.optString("testDeviceId", "");
|
|
@@ -55,6 +57,8 @@ public class ConsentExecutor {
|
|
|
55
57
|
if (options.has("tagForUnderAgeOfConsent")) {
|
|
56
58
|
tagForUnderAgeOfConsent = options.getBoolean("tagForUnderAgeOfConsent");
|
|
57
59
|
}
|
|
60
|
+
|
|
61
|
+
tempShowFormIfRequired = options.optBoolean("showFormIfRequired", true);
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
if (resetConsent) {
|
|
@@ -62,6 +66,8 @@ public class ConsentExecutor {
|
|
|
62
66
|
|
|
63
67
|
}
|
|
64
68
|
|
|
69
|
+
final boolean showFormIfRequired = tempShowFormIfRequired;
|
|
70
|
+
|
|
65
71
|
ConsentRequestParameters.Builder paramsBuilder = new ConsentRequestParameters.Builder();
|
|
66
72
|
paramsBuilder.setTagForUnderAgeOfConsent(tagForUnderAgeOfConsent);
|
|
67
73
|
|
|
@@ -94,21 +100,25 @@ public class ConsentExecutor {
|
|
|
94
100
|
|
|
95
101
|
fireEvent("on.consent.info.update", null);
|
|
96
102
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
if (showFormIfRequired) {
|
|
104
|
+
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
|
|
105
|
+
activity,
|
|
106
|
+
(FormError loadAndShowError) -> {
|
|
107
|
+
if (loadAndShowError != null) {
|
|
108
|
+
|
|
109
|
+
sendErrorEvent(loadAndShowError);
|
|
110
|
+
callbackContext.error(loadAndShowError.getMessage());
|
|
111
|
+
} else {
|
|
112
|
+
fireEvent("on.consent.form.dismissed", null);
|
|
113
|
+
sendConsentStatus(callbackContext);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
105
118
|
|
|
106
|
-
|
|
119
|
+
sendConsentStatus(callbackContext);
|
|
120
|
+
}
|
|
107
121
|
|
|
108
|
-
sendConsentStatus(callbackContext);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
122
|
},
|
|
113
123
|
(FormError requestConsentError) -> {
|
|
114
124
|
|
|
@@ -128,15 +138,20 @@ public class ConsentExecutor {
|
|
|
128
138
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(cordova.getActivity());
|
|
129
139
|
JSONObject tcData = new JSONObject();
|
|
130
140
|
|
|
131
|
-
String
|
|
141
|
+
Map<String, ?> allEntries = prefs.getAll();
|
|
142
|
+
for (Map.Entry<String, ?> entry : allEntries.entrySet()) {
|
|
143
|
+
if (entry.getKey().startsWith("IABTCF_")) {
|
|
144
|
+
tcData.put(entry.getKey(), entry.getValue());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
132
148
|
String purposeConsents = prefs.getString("IABTCF_PurposeConsents", "");
|
|
133
149
|
String purposeLegitimateInterests = prefs.getString("IABTCF_PurposeLegitimateInterests", "");
|
|
134
150
|
String vendorConsents = prefs.getString("IABTCF_VendorConsents", "");
|
|
135
151
|
int gdprApplies = prefs.getInt("IABTCF_gdprApplies", 0);
|
|
136
152
|
|
|
137
|
-
tcData.put("tcString", tcString);
|
|
138
153
|
tcData.put("purposeConsents", purposeConsents);
|
|
139
|
-
tcData.put("purposeLegitimateInterests", purposeLegitimateInterests);
|
|
154
|
+
tcData.put("purposeLegitimateInterests", purposeLegitimateInterests);
|
|
140
155
|
tcData.put("vendorConsents", vendorConsents);
|
|
141
156
|
tcData.put("gdprApplies", gdprApplies);
|
|
142
157
|
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
BOOL resetConsent = options[@"reset"] ? [options[@"reset"] boolValue] : NO;
|
|
27
27
|
BOOL tagForUnderAgeOfConsent = options[@"tagForUnderAgeOfConsent"] ? [options[@"tagForUnderAgeOfConsent"] boolValue] : NO;
|
|
28
28
|
|
|
29
|
+
BOOL showFormIfRequired = options[@"showFormIfRequired"] ? [options[@"showFormIfRequired"] boolValue] : YES;
|
|
30
|
+
|
|
29
31
|
if (resetConsent) {
|
|
30
32
|
[UMPConsentInformation.sharedInstance reset];
|
|
31
33
|
|
|
@@ -65,22 +67,24 @@
|
|
|
65
67
|
|
|
66
68
|
[self.plugin fireEvent:@"document" event:@"on.consent.info.update" withData:nil];
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
if (showFormIfRequired) {
|
|
71
|
+
[UMPConsentForm loadAndPresentIfRequiredFromViewController:self.plugin.viewController completionHandler:^(NSError * _Nullable loadAndPresentError) {
|
|
72
|
+
|
|
73
|
+
if (loadAndPresentError) {
|
|
74
|
+
[self sendErrorEvent:loadAndPresentError];
|
|
75
|
+
if (command) {
|
|
76
|
+
CDVPluginResult* errRes = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:loadAndPresentError.localizedDescription];
|
|
77
|
+
[self.plugin.commandDelegate sendPluginResult:errRes callbackId:command.callbackId];
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
[self.plugin fireEvent:@"document" event:@"on.consent.form.dismissed" withData:nil];
|
|
81
|
+
[self sendConsentStatus:command];
|
|
76
82
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
[self.plugin fireEvent:@"document" event:@"on.consent.form.dismissed" withData:nil];
|
|
83
|
+
}];
|
|
84
|
+
} else {
|
|
80
85
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}];
|
|
86
|
+
[self sendConsentStatus:command];
|
|
87
|
+
}
|
|
84
88
|
}];
|
|
85
89
|
|
|
86
90
|
} @catch (NSException *exception) {
|
|
@@ -98,14 +102,19 @@
|
|
|
98
102
|
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
|
|
99
103
|
NSMutableDictionary *tcData = [NSMutableDictionary dictionary];
|
|
100
104
|
|
|
101
|
-
|
|
105
|
+
NSDictionary *allDefaults = [prefs dictionaryRepresentation];
|
|
106
|
+
for (NSString *key in allDefaults) {
|
|
107
|
+
if ([key hasPrefix:@"IABTCF_"]) {
|
|
108
|
+
tcData[key] = allDefaults[key];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
102
112
|
NSString *purposeConsents = [prefs stringForKey:@"IABTCF_PurposeConsents"] ?: @"";
|
|
103
113
|
NSString *purposeLegitimateInterests = [prefs stringForKey:@"IABTCF_PurposeLegitimateInterests"] ?: @"";
|
|
104
114
|
NSString *vendorConsents = [prefs stringForKey:@"IABTCF_VendorConsents"] ?: @"";
|
|
105
115
|
NSString *additionalConsent = [prefs stringForKey:@"IABTCF_AddtlConsent"] ?: @"";
|
|
106
116
|
NSInteger gdprApplies = [prefs integerForKey:@"IABTCF_gdprApplies"];
|
|
107
117
|
|
|
108
|
-
tcData[@"tcString"] = tcString;
|
|
109
118
|
tcData[@"purposeConsents"] = purposeConsents;
|
|
110
119
|
tcData[@"purposeLegitimateInterests"] = purposeLegitimateInterests;
|
|
111
120
|
tcData[@"vendorConsents"] = vendorConsents;
|
package/www/admob-nextgen.js
CHANGED
|
@@ -15,10 +15,12 @@ var AdMobNextGen = {
|
|
|
15
15
|
},
|
|
16
16
|
|
|
17
17
|
setRequestConfiguration: function (config, success, error) {
|
|
18
|
+
config = config || {};
|
|
18
19
|
exec(success, error, 'AdMobNextGen', 'setRequestConfiguration', [config]);
|
|
19
20
|
},
|
|
20
21
|
|
|
21
22
|
requestConsentInfo: function (options, success, error) {
|
|
23
|
+
options = options || {};
|
|
22
24
|
exec(success, error, 'AdMobNextGen', 'requestConsentInfo', [options]);
|
|
23
25
|
},
|
|
24
26
|
|