emi-indo-cordova-plugin-admob 1.6.6 → 1.6.7

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.
@@ -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: # Replace with a single Ko-fi username
7
- tidelift: # npm/emi-indo-cordova-plugin-admob
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
@@ -102,7 +102,7 @@ https://developers.google.com/admob/ios/quick-start
102
102
 
103
103
  ## 💰Sponsor this project
104
104
  [![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://paypal.me/emiindo)
105
-
105
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](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
 
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "Cordova Plugin Admob Android IOS Support Capacitor",
5
5
  "cordova": {
6
6
  "id": "emi-indo-cordova-plugin-admob",
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.6">
3
+ id="emi-indo-cordova-plugin-admob" version="1.6.7">
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
@@ -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 == "collapsibleBannerAd") {
1215
+ } else if (action == "metaData") {
1206
1216
  val options = args.getJSONObject(0)
1217
+ val useCustomConsentManager = options.optBoolean("useCustomConsentManager")
1207
1218
  if (mActivity != null) {
1208
- mActivity!!.runOnUiThread {
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
- callbackContext.error("Error registering WebView: ${e.message}")
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
- val webView = cWebView?.view
1309
+ val webView = cWebView?.view
1308
1310
 
1309
- if (webView is WebView) {
1310
- webView.loadUrl(url)
1311
- callbackContext.success("URL loaded successfully: $url")
1312
- } else {
1313
- callbackContext.error("WebView is not available.")
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
- cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
1489
+ cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
1488
1490
 
1489
1491
  bannerOverlappingToZero()
1490
1492
 
@@ -1599,30 +1601,30 @@ class emiAdmobPlugin : CordovaPlugin() {
1599
1601
 
1600
1602
 
1601
1603
 
1602
- // fix https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/issues/26
1603
- private fun bannerOverlapping() {
1604
- if (bannerView != null && mActivity != null && cWebView != null) {
1605
- mActivity!!.runOnUiThread {
1606
- try {
1607
- val bannerHeightInPx = bannerView!!.height
1608
- val displayMetrics = DisplayMetrics()
1609
- mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
1610
- val screenHeightInPx = displayMetrics.heightPixels
1611
-
1612
- // Adjust the WebView height to account for the banner ad
1613
- val webViewHeight = screenHeightInPx - (adSize.height + overlappingHeight)
1614
- val layoutParams = cWebView!!.view.layoutParams
1615
- layoutParams.height = webViewHeight
1616
- cWebView!!.view.layoutParams = layoutParams
1617
-
1618
- // Log for debugging
1619
- Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
1620
- } catch (e: Exception) {
1621
- Log.e("AdmobPlugin", "Error adjusting WebView for banner: ${e.message}")
1622
- }
1604
+ // fix https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/issues/26
1605
+ private fun bannerOverlapping() {
1606
+ if (bannerView != null && mActivity != null && cWebView != null) {
1607
+ mActivity!!.runOnUiThread {
1608
+ try {
1609
+ val bannerHeightInPx = bannerView!!.height
1610
+ val displayMetrics = DisplayMetrics()
1611
+ mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
1612
+ val screenHeightInPx = displayMetrics.heightPixels
1613
+
1614
+ // Adjust the WebView height to account for the banner ad
1615
+ val webViewHeight = screenHeightInPx - (adSize.height + overlappingHeight)
1616
+ val layoutParams = cWebView!!.view.layoutParams
1617
+ layoutParams.height = webViewHeight
1618
+ cWebView!!.view.layoutParams = layoutParams
1619
+
1620
+ // Log for debugging
1621
+ Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
1622
+ } catch (e: Exception) {
1623
+ Log.e("AdmobPlugin", "Error adjusting WebView for banner: ${e.message}")
1623
1624
  }
1624
1625
  }
1625
1626
  }
1627
+ }
1626
1628
 
1627
1629
 
1628
1630
 
@@ -1785,7 +1787,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1785
1787
  try {
1786
1788
  (brandSafetyUrls as ArrayList<String>).add(brandSafetyArr.getString(i))
1787
1789
  } catch (e: JSONException) {
1788
- // e.printStackTrace();
1790
+ e.printStackTrace();
1789
1791
  }
1790
1792
  }
1791
1793
  }
@@ -1794,7 +1796,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1794
1796
  this.ppIdVl = ppId
1795
1797
  this.cURLVl = ctURL
1796
1798
  } catch (e: JSONException) {
1797
- // e.printStackTrace();
1799
+ e.printStackTrace();
1798
1800
  }
1799
1801
  }
1800
1802
 
@@ -1808,7 +1810,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1808
1810
  }
1809
1811
  }
1810
1812
  } catch (e: JSONException) {
1811
- // e.printStackTrace();
1813
+ e.printStackTrace();
1812
1814
  }
1813
1815
  }
1814
1816
 
@@ -1835,7 +1837,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1835
1837
  }
1836
1838
  }
1837
1839
  val sdkVersion = MobileAds.getVersion().toString()
1838
- val mStatus = consentInformation!!.consentStatus.toString()
1840
+ val mStatus = consentInformation?.consentStatus.toString()
1839
1841
 
1840
1842
  val adapterInfo = StringBuilder()
1841
1843
  for (adapterClass in statusMap.keys) {
@@ -2272,8 +2274,4 @@ class emiAdmobPlugin : CordovaPlugin() {
2272
2274
  private const val LAST_ACCESS_SUFFIX = "_last_access"
2273
2275
  private const val EXPIRATION_TIME = 360L * 24 * 60 * 60 * 1000
2274
2276
  }
2275
- }
2276
-
2277
-
2278
-
2279
-
2277
+ }
@@ -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