emi-indo-cordova-plugin-admob 1.6.6 → 1.6.8
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/.github/FUNDING.yml +2 -2
- package/README.md +2 -2
- package/example/www/index.html +0 -0
- package/example/www/js/bannerAd.js +2 -1
- package/example/www/js/deviceready.js +12 -3
- package/package.json +1 -1
- package/plugin.xml +7 -4
- package/src/android/emiAdmobPlugin.kt +53 -51
- package/src/ios/emiAdmobPlugin.m +12 -1
- package/www/emiAdmobPlugin.js +3 -0
package/.github/FUNDING.yml
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4
4
|
patreon: # Replace with a single Patreon username
|
5
5
|
open_collective: # Replace with a single Open Collective username
|
6
|
-
ko_fi:
|
7
|
-
tidelift:
|
6
|
+
ko_fi: emiindo
|
7
|
+
tidelift: # npm/emi-indo-cordova-plugin-admob
|
8
8
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9
9
|
liberapay: # Replace with a single Liberapay username
|
10
10
|
issuehunt: # Replace with a single IssueHunt username
|
package/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
- AdSense New [example ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/adSense.js)
|
9
9
|
|
10
10
|
|
11
|
-
### Mobile Ads SDK (Android: 23.
|
11
|
+
### Mobile Ads SDK (Android: 23.6.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
|
12
12
|
### User Messaging Platform (UMP Android: 3.1.0) [Release Notes:](https://developers.google.com/admob/android/privacy/release-notes)
|
13
13
|
|
14
14
|
### Mobile Ads SDK (IOS: 11.12.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
|
@@ -102,7 +102,7 @@ https://developers.google.com/admob/ios/quick-start
|
|
102
102
|
|
103
103
|
## 💰Sponsor this project
|
104
104
|
[](https://paypal.me/emiindo)
|
105
|
-
|
105
|
+
[](https://ko-fi.com/F1F16NI8H)
|
106
106
|
## [Check all release notes:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/)
|
107
107
|
|
108
108
|
|
package/example/www/index.html
CHANGED
File without changes
|
@@ -80,8 +80,17 @@ document.addEventListener("deviceready", function () {
|
|
80
80
|
|
81
81
|
cordova.plugins.emiAdmobPlugin.requestIDFA(); // requestTrackingAuthorization
|
82
82
|
|
83
|
-
}
|
84
|
-
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
// deactivate Google's consent
|
87
|
+
/*
|
88
|
+
cordova.plugins.emiAdmobPlugin.metaData({
|
89
|
+
|
90
|
+
useCustomConsentManager: false // Default false only android
|
91
|
+
|
92
|
+
});
|
93
|
+
*/
|
85
94
|
|
86
95
|
// AdMob Sdk initialize
|
87
96
|
|
@@ -121,4 +130,4 @@ document.addEventListener("deviceready", function () {
|
|
121
130
|
|
122
131
|
|
123
132
|
|
124
|
-
}, false);
|
133
|
+
}, false);
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
2
2
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
-
id="emi-indo-cordova-plugin-admob" version="1.6.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="1.6.8">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova Plugin Admob Android IOS</description>
|
@@ -40,7 +40,10 @@
|
|
40
40
|
<uses-permission android:name="android.permission.INTERNET" />
|
41
41
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
42
42
|
</config-file>
|
43
|
-
|
43
|
+
|
44
|
+
<config-file parent="./application" target="AndroidManifest.xml">
|
45
|
+
<property android:name="android.adservices.AD_SERVICES_CONFIG" android:resource="@xml/gma_ad_services_config" tools:replace="android:resource" />
|
46
|
+
</config-file>
|
44
47
|
|
45
48
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
46
49
|
<activity
|
@@ -64,7 +67,7 @@
|
|
64
67
|
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
|
65
68
|
|
66
69
|
<preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
|
67
|
-
<preference name="PLAY_SERVICES_VERSION" default="23.
|
70
|
+
<preference name="PLAY_SERVICES_VERSION" default="23.6.0" />
|
68
71
|
|
69
72
|
<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />
|
70
73
|
|
@@ -306,4 +309,4 @@
|
|
306
309
|
</podspec>
|
307
310
|
|
308
311
|
</platform>
|
309
|
-
</plugin>
|
312
|
+
</plugin>
|
@@ -138,6 +138,8 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
138
138
|
|
139
139
|
private var isUsingAdManagerRequest = false
|
140
140
|
|
141
|
+
private var isCustomConsentManager = false
|
142
|
+
|
141
143
|
|
142
144
|
override fun initialize(cordova: CordovaInterface, webView: CordovaWebView) {
|
143
145
|
super.initialize(cordova, webView)
|
@@ -234,6 +236,14 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
234
236
|
setUsingAdManagerRequest(setAdRequest)
|
235
237
|
this.isResponseInfo = responseInfo
|
236
238
|
this.setDebugGeography = setDebugGeography
|
239
|
+
|
240
|
+
// If the user uses a custom CMP
|
241
|
+
if (this.isCustomConsentManager) {
|
242
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.custom.consent.manager.used');")
|
243
|
+
initializeMobileAdsSdk()
|
244
|
+
return@runOnUiThread
|
245
|
+
}
|
246
|
+
|
237
247
|
val params: ConsentRequestParameters
|
238
248
|
if (this.setDebugGeography) {
|
239
249
|
val debugSettings = mActivity?.let {
|
@@ -1202,19 +1212,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1202
1212
|
}
|
1203
1213
|
}
|
1204
1214
|
return true
|
1205
|
-
} else if (action == "
|
1215
|
+
} else if (action == "metaData") {
|
1206
1216
|
val options = args.getJSONObject(0)
|
1217
|
+
val useCustomConsentManager = options.optBoolean("useCustomConsentManager")
|
1207
1218
|
if (mActivity != null) {
|
1208
|
-
|
1209
|
-
val enableCollapsible = options.optBoolean("enabledBannerCollapsible")
|
1210
|
-
val collapsible = options.optString("collapsiblePosition")
|
1211
|
-
try {
|
1212
|
-
this.isCollapsible = enableCollapsible
|
1213
|
-
this.collapsiblePos = collapsible
|
1214
|
-
} catch (e: Exception) {
|
1215
|
-
callbackContext.error(e.toString())
|
1216
|
-
}
|
1217
|
-
}
|
1219
|
+
this.isCustomConsentManager = useCustomConsentManager
|
1218
1220
|
}
|
1219
1221
|
return true
|
1220
1222
|
} else if (action == "hideBannerAd") {
|
@@ -1296,7 +1298,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1296
1298
|
callbackContext.error("View is not a WebView.")
|
1297
1299
|
}
|
1298
1300
|
} catch (e: Exception) {
|
1299
|
-
|
1301
|
+
callbackContext.error("Error registering WebView: ${e.message}")
|
1300
1302
|
}
|
1301
1303
|
|
1302
1304
|
}
|
@@ -1304,14 +1306,14 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1304
1306
|
|
1305
1307
|
private fun loadUrl(url: String, callbackContext: CallbackContext) {
|
1306
1308
|
try {
|
1307
|
-
|
1309
|
+
val webView = cWebView?.view
|
1308
1310
|
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1311
|
+
if (webView is WebView) {
|
1312
|
+
webView.loadUrl(url)
|
1313
|
+
callbackContext.success("URL loaded successfully: $url")
|
1314
|
+
} else {
|
1315
|
+
callbackContext.error("WebView is not available.")
|
1316
|
+
}
|
1315
1317
|
|
1316
1318
|
} catch (e: Exception) {
|
1317
1319
|
callbackContext.error("Error loading URL: ${e.message}")
|
@@ -1484,7 +1486,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1484
1486
|
put("responseInfoAdapterResponses", adapterResponses)
|
1485
1487
|
}
|
1486
1488
|
|
1487
|
-
|
1489
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
|
1488
1490
|
|
1489
1491
|
bannerOverlappingToZero()
|
1490
1492
|
|
@@ -1521,7 +1523,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1521
1523
|
bannerOverlapping()
|
1522
1524
|
}
|
1523
1525
|
|
1524
|
-
|
1526
|
+
val bannerHeight= adSize.height;
|
1527
|
+
|
1528
|
+
val bannerLoadEventData = String.format(Locale.US, "{\"height\": %d}", bannerHeight)
|
1529
|
+
|
1530
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load', $bannerLoadEventData);")
|
1525
1531
|
|
1526
1532
|
val eventData = String.format(
|
1527
1533
|
"{\"collapsible\": \"%s\"}",
|
@@ -1599,30 +1605,30 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1599
1605
|
|
1600
1606
|
|
1601
1607
|
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
}
|
1608
|
+
// fix https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/issues/26
|
1609
|
+
private fun bannerOverlapping() {
|
1610
|
+
if (bannerView != null && mActivity != null && cWebView != null) {
|
1611
|
+
mActivity!!.runOnUiThread {
|
1612
|
+
try {
|
1613
|
+
val bannerHeightInPx = bannerView!!.height
|
1614
|
+
val displayMetrics = DisplayMetrics()
|
1615
|
+
mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
|
1616
|
+
val screenHeightInPx = displayMetrics.heightPixels
|
1617
|
+
|
1618
|
+
// Adjust the WebView height to account for the banner ad
|
1619
|
+
val webViewHeight = screenHeightInPx - (adSize.height + overlappingHeight)
|
1620
|
+
val layoutParams = cWebView!!.view.layoutParams
|
1621
|
+
layoutParams.height = webViewHeight
|
1622
|
+
cWebView!!.view.layoutParams = layoutParams
|
1623
|
+
|
1624
|
+
// Log for debugging
|
1625
|
+
Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
|
1626
|
+
} catch (e: Exception) {
|
1627
|
+
Log.e("AdmobPlugin", "Error adjusting WebView for banner: ${e.message}")
|
1623
1628
|
}
|
1624
1629
|
}
|
1625
1630
|
}
|
1631
|
+
}
|
1626
1632
|
|
1627
1633
|
|
1628
1634
|
|
@@ -1785,7 +1791,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1785
1791
|
try {
|
1786
1792
|
(brandSafetyUrls as ArrayList<String>).add(brandSafetyArr.getString(i))
|
1787
1793
|
} catch (e: JSONException) {
|
1788
|
-
|
1794
|
+
e.printStackTrace();
|
1789
1795
|
}
|
1790
1796
|
}
|
1791
1797
|
}
|
@@ -1794,7 +1800,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1794
1800
|
this.ppIdVl = ppId
|
1795
1801
|
this.cURLVl = ctURL
|
1796
1802
|
} catch (e: JSONException) {
|
1797
|
-
|
1803
|
+
e.printStackTrace();
|
1798
1804
|
}
|
1799
1805
|
}
|
1800
1806
|
|
@@ -1808,7 +1814,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1808
1814
|
}
|
1809
1815
|
}
|
1810
1816
|
} catch (e: JSONException) {
|
1811
|
-
|
1817
|
+
e.printStackTrace();
|
1812
1818
|
}
|
1813
1819
|
}
|
1814
1820
|
|
@@ -1835,7 +1841,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1835
1841
|
}
|
1836
1842
|
}
|
1837
1843
|
val sdkVersion = MobileAds.getVersion().toString()
|
1838
|
-
val mStatus = consentInformation
|
1844
|
+
val mStatus = consentInformation?.consentStatus.toString()
|
1839
1845
|
|
1840
1846
|
val adapterInfo = StringBuilder()
|
1841
1847
|
for (adapterClass in statusMap.keys) {
|
@@ -2272,8 +2278,4 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2272
2278
|
private const val LAST_ACCESS_SUFFIX = "_last_access"
|
2273
2279
|
private const val EXPIRATION_TIME = 360L * 24 * 60 * 60 * 1000
|
2274
2280
|
}
|
2275
|
-
}
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2281
|
+
}
|
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -1446,8 +1446,19 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1446
1446
|
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
1447
1447
|
[self fireEvent:@"" event:@"on.is.collapsible" withData:jsonString];
|
1448
1448
|
}
|
1449
|
+
|
1450
|
+
// Get the banner height
|
1451
|
+
CGFloat bannerHeight = bannerView.bounds.size.height;
|
1452
|
+
|
1449
1453
|
|
1450
|
-
|
1454
|
+
|
1455
|
+
// Prepare height data for banner load event
|
1456
|
+
NSDictionary *bannerLoadData = @{@"height" : @(bannerHeight)};
|
1457
|
+
NSData *bannerLoadJsonData = [NSJSONSerialization dataWithJSONObject:bannerLoadData options:0 error:&error];
|
1458
|
+
NSString *bannerLoadJsonString = [[NSString alloc] initWithData:bannerLoadJsonData encoding:NSUTF8StringEncoding];
|
1459
|
+
|
1460
|
+
// Fire the banner load event with the height data
|
1461
|
+
[self fireEvent:@"" event:@"on.banner.load" withData:bannerLoadJsonString];
|
1451
1462
|
|
1452
1463
|
if (auto_Show && self.bannerView) {
|
1453
1464
|
[self addBannerViewToView:command];
|
package/www/emiAdmobPlugin.js
CHANGED
@@ -73,6 +73,9 @@ exports.forceDisplayPrivacyForm = function (success, error) {
|
|
73
73
|
exec(success, error, 'emiAdmobPlugin', 'forceDisplayPrivacyForm', []); // only IOS
|
74
74
|
};
|
75
75
|
|
76
|
+
exports.metaData = function (options, success, error) {
|
77
|
+
exec(success, error, 'emiAdmobPlugin', 'metaData', [options]);
|
78
|
+
};
|
76
79
|
|
77
80
|
// ( only Android )
|
78
81
|
// only isUsingAdManagerRequest: true
|