emi-indo-cordova-plugin-admob 1.6.3 → 1.6.5

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 CHANGED
@@ -125,9 +125,14 @@ https://developers.google.com/admob/ios/quick-start
125
125
  <li> impression-level-ad-revenue</li>
126
126
  </ul>
127
127
  </details>
128
+ ## Version locking the plugin during production is highly recommended.
128
129
 
129
- ## Installation
130
+ - Example cordova plugin add emi-indo-cordova-plugin-admob@1.6.0 --save --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx
131
+ - View plugin version: https://www.npmjs.com/package/emi-indo-cordova-plugin-admob?activeTab=versions
132
+ - Release notes: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases
130
133
 
134
+ ## Installation
135
+ - Recommendation to version-lock the plugin during production
131
136
  - Only platform Android
132
137
  ```sh
133
138
  cordova plugin add emi-indo-cordova-plugin-admob --save --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx
@@ -345,7 +350,7 @@ document.addEventListener('on.appOpenAd.loaded', () => {
345
350
  </pre>
346
351
  </details>
347
352
 
348
- - [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/appOpenAd.js)
353
+ - [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/appOpenAd.js)
349
354
 
350
355
 
351
356
 
@@ -448,7 +453,7 @@ console.log("Collapsible Status: " + event.collapsible);
448
453
  </pre>
449
454
  </details>
450
455
 
451
- [FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/bannerAd.js)
456
+ [FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/bannerAd.js)
452
457
 
453
458
 
454
459
  ## Interstitial ADS
@@ -511,7 +516,7 @@ document.addEventListener('on.interstitial.dismissed', () => {
511
516
  </details>
512
517
 
513
518
 
514
- [FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/interstitialAd.js)
519
+ [FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/interstitialAd.js)
515
520
 
516
521
 
517
522
 
@@ -640,7 +645,7 @@ document.addEventListener('on.rewarded.dismissed', () => {
640
645
  </pre>
641
646
  </details>
642
647
 
643
- [FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/Example/www/js/rewardedAd.js)
648
+ [FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/rewardedAd.js)
644
649
 
645
650
 
646
651
 
@@ -14,7 +14,7 @@
14
14
  "author": "Apache Cordova Team",
15
15
  "license": "Apache-2.0",
16
16
  "devDependencies": {
17
- "emi-indo-cordova-plugin-admob": "^1.6.3"
17
+ "emi-indo-cordova-plugin-admob": "^1.6.4"
18
18
  },
19
19
  "cordova": {
20
20
  "plugins": {
@@ -6,12 +6,13 @@
6
6
  <script src="js/bannerAd.js" defer></script>
7
7
  <script src="js/interstitialAd.js" defer></script>
8
8
  <script src="js/rewardedAd.js" defer></script>
9
+ <script src="js/rewardedInterstitialAd.js" defer></script>
9
10
  </head>
10
11
  <body>
11
12
 
12
13
 
13
14
  <label for="event">Debug Event All response :</label>
14
- <textarea id="log" name="log" rows="5" cols="40"></textarea>
15
+ <textarea id="log" name="log" rows="20" cols="40"></textarea>
15
16
 
16
17
  <p> <button onclick="loadAppOpen();">Auto Show App Open Ad</button></p>
17
18
 
@@ -22,6 +23,9 @@
22
23
  <p> <button onclick="loadRewarded();">Load Rewarded Ad</button></p>
23
24
  <p> <button onclick="showRewarded();">Show Rewarded Ad</button></p>
24
25
 
26
+ <p> <button onclick="loadRewardedInt();">Load Rewarded Int Ad</button></p>
27
+ <p> <button onclick="showRewardedInt();">Show Rewarded int Ad</button></p>
28
+
25
29
  <p> <button onclick="cleanText();">Clean response Text</button></p>
26
30
 
27
31
  </body>
@@ -72,7 +72,16 @@ document.addEventListener('on.appOpenAd.loaded', () => {
72
72
  document.addEventListener('on.appOpenAd.failed.loaded', (error) => {
73
73
  isAppOpenAdLoad = false;
74
74
  console.log("on.appOpenAd.failed.loaded" + JSON.stringify(error));
75
-
75
+ /*
76
+ error.code
77
+ error.message
78
+ error.domain
79
+ error.responseInfoId
80
+ error.responseInfoExtras
81
+ error.responseInfoAdapter
82
+ error.responseInfoMediationAdapterClassName
83
+ error.responseInfoAdapterResponses
84
+ */
76
85
  window.log.value += ("\n on.appOpenAd.failed.loaded" + JSON.stringify(error));
77
86
  });
78
87
 
@@ -128,6 +128,18 @@ document.addEventListener('on.is.collapsible', function (event) {
128
128
 
129
129
  document.addEventListener('on.banner.failed.load', (error) => {
130
130
  console.log("on.banner.failed.load" + JSON.stringify(error));
131
+
132
+ /*
133
+ error.code
134
+ error.message
135
+ error.domain
136
+ error.responseInfoId
137
+ error.responseInfoExtras
138
+ error.responseInfoAdapter
139
+ error.responseInfoMediationAdapterClassName
140
+ error.responseInfoAdapterResponses
141
+ */
142
+
131
143
  });
132
144
 
133
145
 
@@ -67,6 +67,17 @@ document.addEventListener('on.interstitial.dismissed', () => {
67
67
  document.addEventListener('on.interstitial.failed.load', (error) => {
68
68
  isInterstitialLoad = false;
69
69
  console.log("on.interstitial.failed.load" + JSON.stringify(error));
70
+
71
+ /*
72
+ error.code
73
+ error.message
74
+ error.domain
75
+ error.responseInfoId
76
+ error.responseInfoExtras
77
+ error.responseInfoAdapter
78
+ error.responseInfoMediationAdapterClassName
79
+ error.responseInfoAdapterResponses
80
+ */
70
81
 
71
82
  window.log.value += ("\n on.interstitial.failed.load" + JSON.stringify(error));
72
83
  });
@@ -52,6 +52,17 @@ document.addEventListener('on.rewarded.failed.load', (error) => {
52
52
  isRewardedLoad = false;
53
53
  console.log("on.rewarded.failed.load" + JSON.stringify(error));
54
54
 
55
+ /*
56
+ error.code
57
+ error.message
58
+ error.domain
59
+ error.responseInfoId
60
+ error.responseInfoExtras
61
+ error.responseInfoAdapter
62
+ error.responseInfoMediationAdapterClassName
63
+ error.responseInfoAdapterResponses
64
+ */
65
+
55
66
  window.log.value += ("\n on.rewarded.failed.load" + JSON.stringify(error));
56
67
  });
57
68
 
@@ -77,7 +88,7 @@ document.addEventListener('on.reward.userEarnedReward', (rewarded) => {
77
88
  // all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
78
89
  document.addEventListener('on.rewarded.dismissed', () => {
79
90
  isRewardedLoad = false;
80
- console.log("on interstitial Ad dismissed");
91
+ console.log("on rewarded Ad dismissed");
81
92
  console.log("you can load ads automatically after the ads are closed by users");
82
93
  loadRewarded();
83
94
 
@@ -0,0 +1,135 @@
1
+
2
+
3
+ let isRewardedIntLoad = false;
4
+
5
+ function loadRewardedInt() {
6
+
7
+ if (typeof cordova !== 'undefined') {
8
+ cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd({ adUnitId: Rewarded_Interstitial_ID, autoShow: false });
9
+ }
10
+
11
+ }
12
+
13
+ function showRewardedInt() {
14
+
15
+ if (typeof cordova !== 'undefined') {
16
+ if (isRewardedIntLoad) {
17
+ cordova.plugins.emiAdmobPlugin.showRewardedInterstitialAd();
18
+ }
19
+ }
20
+
21
+ }
22
+
23
+
24
+ /*
25
+ on.rewardedInt.loaded
26
+ on.rewardedInt.failed.load
27
+ on.rewardedInt.click
28
+ on.rewardedInt.dismissed
29
+ on.rewardedInt.failed.show
30
+ on.rewardedInt.impression
31
+ on.rewardedInt.showed
32
+ on.rewardedInt.userEarnedReward
33
+ // new
34
+ on.rewardedInt.revenue
35
+ on.rewardedInt.ad.skip
36
+ on.rewardedIntAd.responseInfo
37
+
38
+ */
39
+
40
+
41
+
42
+ document.addEventListener('on.rewardedInt.loaded', () => {
43
+ isRewardedIntLoad = true;
44
+ console.log("on.rewardedInt.loaded");
45
+ window.log.value += ("\n on.rewardedInt.loaded");
46
+ });
47
+
48
+
49
+ document.addEventListener('on.rewardedInt.failed.load', (error) => {
50
+ isRewardedIntLoad = false;
51
+ console.log("on.rewardedInt.failed.load" + JSON.stringify(error));
52
+
53
+ /*
54
+ error.code
55
+ error.message
56
+ error.domain
57
+ error.responseInfoId
58
+ error.responseInfoExtras
59
+ error.responseInfoAdapter
60
+ error.responseInfoMediationAdapterClassName
61
+ error.responseInfoAdapterResponses
62
+ */
63
+
64
+ window.log.value += ("\n on.rewardedInt.failed.load" + JSON.stringify(error));
65
+ });
66
+
67
+
68
+ document.addEventListener('on.rewardedInt.failed.show', (error) => {
69
+ isRewardedIntLoad = false;
70
+ console.log("on.rewardedInt.failed.show" + JSON.stringify(error));
71
+
72
+ window.log.value += ("\n on.rewardedInt.failed.show" + JSON.stringify(error));
73
+ });
74
+
75
+
76
+ document.addEventListener('on.rewardedInt.userEarnedReward', (rewarded) => {
77
+ // Give gifts to users here
78
+ isRewardedIntLoad = false;
79
+ console.log("Give gifts to users here" + JSON.stringify(rewarded));
80
+ // const rewardAmount = rewarded.amount;
81
+ // const rewardType = rewarded.currency;
82
+ window.log.value += ("\n Give gifts to users here" + JSON.stringify(rewarded));
83
+ });
84
+
85
+
86
+ // all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
87
+ document.addEventListener('on.rewardedInt.dismissed', () => {
88
+ isRewardedIntLoad = false;
89
+ console.log("on.rewardedInt.dismissed");
90
+ console.log("you can load ads automatically after the ads are closed by users");
91
+ loadRewardedInt();
92
+
93
+ window.log.value += ("\n you can load ads automatically after the ads are closed by users");
94
+
95
+ });
96
+
97
+
98
+
99
+
100
+
101
+ /*
102
+ // DEBUG
103
+ // isResponseInfo: true, // debug Default false
104
+ document.addEventListener('on.rewardedIntAd.responseInfo', (data) => {
105
+
106
+ console.log("on.rewardedIntAd.responseInfo" + JSON.stringify(data));
107
+ if (window.log) window.log.value += ("\n on.rewardedIntAd.responseInfo" + JSON.stringify(data));
108
+ });
109
+
110
+ */
111
+
112
+
113
+
114
+
115
+
116
+ /*
117
+ https://support.google.com/admob/answer/11322405
118
+
119
+ Turn on the setting for impression-level ad revenue in your AdMob account:
120
+ Sign in to your AdMob account at https://apps.admob.com.
121
+ Click Settings in the sidebar.
122
+ Click the Account tab.
123
+ In the Account controls section, click the Impression-level ad revenue toggle to turn on this setting.
124
+ */
125
+
126
+ document.addEventListener('on.rewardedInt.revenue', (data) => {
127
+
128
+ console.log(data.value)
129
+ console.log(data.currencyCode)
130
+ console.log(data.precision)
131
+ console.log(data.adUnitId)
132
+
133
+ // console.log("on.rewardedInt.revenue" + JSON.stringify(data));
134
+ if (window.log) window.log.value += ("\n on.rewardedInt.revenue" + JSON.stringify(data));
135
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
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.3">
3
+ id="emi-indo-cordova-plugin-admob" version="1.6.5">
4
4
 
5
5
  <name>emiAdmobPlugin</name>
6
6
  <description>Cordova Plugin Admob Android IOS</description>
@@ -180,6 +180,7 @@ class emiAdmobPlugin : CordovaPlugin() {
180
180
  bannerView!!.loadAd(buildAdRequest())
181
181
  bannerViewLayout!!.addView(bannerView)
182
182
  bannerViewLayout!!.bringToFront()
183
+ bannerViewLayout!!.requestFocus();
183
184
  bannerOverlappingToZero()
184
185
  }
185
186
  } catch (e: Exception) {
@@ -437,31 +438,33 @@ class emiAdmobPlugin : CordovaPlugin() {
437
438
  }
438
439
  }
439
440
 
441
+
440
442
  if (isResponseInfo) {
441
443
  val result = JSONObject()
442
444
  val responseInfo = ad.responseInfo
443
445
  try {
444
- result.put("getResponseId", responseInfo.responseId)
446
+ result.put("getResponseId", responseInfo.responseId.toString())
445
447
  result.put(
446
448
  "getAdapterResponses",
447
- responseInfo.adapterResponses
449
+ responseInfo.adapterResponses.toString()
448
450
  )
449
451
  result.put(
450
452
  "getResponseExtras",
451
- responseInfo.responseExtras
453
+ responseInfo.responseExtras.toString()
452
454
  )
453
455
  result.put(
454
456
  "getMediationAdapterClassName",
455
- responseInfo.mediationAdapterClassName
457
+ responseInfo.mediationAdapterClassName.toString()
456
458
  )
457
459
  result.put("getBundleExtra", mBundleExtra.toString())
458
460
  cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.responseInfo', ${result})")
459
461
  } catch (e: JSONException) {
460
462
  callbackContext.error(e.message)
461
463
  }
462
- }
463
464
 
464
465
 
466
+ }
467
+
465
468
 
466
469
  }
467
470
 
@@ -478,22 +481,22 @@ class emiAdmobPlugin : CordovaPlugin() {
478
481
  PUBLIC_CALLBACKS!!.error(e.toString())
479
482
  }
480
483
  }
481
-
482
484
  override fun onAdFailedToLoad(loadAdError: LoadAdError) {
483
485
  isAppOpenAdShow = false
484
486
  val errorData = JSONObject().apply {
485
- put("responseInfo", loadAdError.responseInfo)
487
+ put("responseInfo", loadAdError.responseInfo.toString())
486
488
  put("code", loadAdError.code)
487
489
  put("message", loadAdError.message)
488
490
  put("domain", loadAdError.domain)
489
491
  put("cause", loadAdError.cause?.toString() ?: "null")
490
492
  }
491
- cWebView!!.loadUrl(
492
- "javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded, ${errorData}');"
493
+ cWebView?.loadUrl(
494
+ "javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded', ${errorData});"
493
495
  )
494
496
  }
497
+
495
498
  })
496
- } catch (e: Exception) {
499
+ } catch (e: Exception) {
497
500
  callbackContext.error(e.toString())
498
501
  }
499
502
  }
@@ -594,13 +597,30 @@ class emiAdmobPlugin : CordovaPlugin() {
594
597
  override fun onAdFailedToLoad(loadAdError: LoadAdError) {
595
598
  mInterstitialAd = null
596
599
  isInterstitialLoad = false
600
+
597
601
  val errorData = JSONObject().apply {
598
- put("responseInfo", loadAdError.responseInfo)
599
602
  put("code", loadAdError.code)
600
603
  put("message", loadAdError.message)
601
604
  put("domain", loadAdError.domain)
602
605
  put("cause", loadAdError.cause?.toString() ?: "null")
606
+
607
+ val responseId = loadAdError.responseInfo?.responseId.toString()
608
+ val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
609
+ val loadedAdapterResponseInfo =
610
+ loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
611
+ val mediationAdapterClassName =
612
+ loadAdError.responseInfo?.mediationAdapterClassName.toString()
613
+ val adapterResponses =
614
+ loadAdError.responseInfo?.adapterResponses.toString()
615
+
616
+ put("responseInfoId", responseId)
617
+ put("responseInfoExtras", responseExtras)
618
+ put("responseInfoAdapter", loadedAdapterResponseInfo)
619
+ put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
620
+ put("responseInfoAdapterResponses", adapterResponses)
603
621
  }
622
+
623
+
604
624
  cWebView!!.loadUrl(
605
625
  "javascript:cordova.fireDocumentEvent('on.interstitial.failed.load', ${errorData});"
606
626
  )
@@ -638,11 +658,28 @@ class emiAdmobPlugin : CordovaPlugin() {
638
658
  isRewardedLoad = false
639
659
 
640
660
  val errorData = JSONObject().apply {
641
- put("responseInfo", loadAdError.responseInfo)
642
661
  put("code", loadAdError.code)
643
662
  put("message", loadAdError.message)
644
663
  put("domain", loadAdError.domain)
645
664
  put("cause", loadAdError.cause?.toString() ?: "null")
665
+
666
+
667
+ val responseId = loadAdError.responseInfo?.responseId.toString()
668
+ val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
669
+ val loadedAdapterResponseInfo =
670
+ loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
671
+ val mediationAdapterClassName =
672
+ loadAdError.responseInfo?.mediationAdapterClassName.toString()
673
+ val adapterResponses =
674
+ loadAdError.responseInfo?.adapterResponses.toString()
675
+
676
+ put("responseInfoId", responseId)
677
+ put("responseInfoExtras", responseExtras)
678
+ put("responseInfoAdapter", loadedAdapterResponseInfo)
679
+ put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
680
+ put("responseInfoAdapterResponses", adapterResponses)
681
+
682
+
646
683
  }
647
684
 
648
685
  cWebView!!.loadUrl(
@@ -888,11 +925,25 @@ class emiAdmobPlugin : CordovaPlugin() {
888
925
  rewardedInterstitialAd = null
889
926
  isRewardedInterstitialLoad = false
890
927
  val errorData = JSONObject().apply {
891
- put("responseInfo", loadAdError.responseInfo)
892
928
  put("code", loadAdError.code)
893
929
  put("message", loadAdError.message)
894
930
  put("domain", loadAdError.domain)
895
931
  put("cause", loadAdError.cause?.toString() ?: "null")
932
+
933
+ val responseId = loadAdError.responseInfo?.responseId.toString()
934
+ val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
935
+ val loadedAdapterResponseInfo =
936
+ loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
937
+ val mediationAdapterClassName =
938
+ loadAdError.responseInfo?.mediationAdapterClassName.toString()
939
+ val adapterResponses =
940
+ loadAdError.responseInfo?.adapterResponses.toString()
941
+
942
+ put("responseInfoId", responseId)
943
+ put("responseInfoExtras", responseExtras)
944
+ put("responseInfoAdapter", loadedAdapterResponseInfo)
945
+ put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
946
+ put("responseInfoAdapterResponses", adapterResponses)
896
947
  }
897
948
  cWebView!!.loadUrl(
898
949
  "javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load', ${errorData});"
@@ -1073,12 +1124,13 @@ class emiAdmobPlugin : CordovaPlugin() {
1073
1124
  try {
1074
1125
  bannerView!!.visibility = View.VISIBLE
1075
1126
  bannerView!!.resume()
1076
- // bannerOverlappingToZero()
1077
1127
 
1078
1128
  if (isOverlapping) {
1079
1129
  bannerOverlapping()
1080
1130
  }
1081
1131
 
1132
+ bannerViewLayout!!.requestFocus();
1133
+
1082
1134
 
1083
1135
  } catch (e: Exception) {
1084
1136
  callbackContext.error(e.toString())
@@ -1164,35 +1216,6 @@ class emiAdmobPlugin : CordovaPlugin() {
1164
1216
  }
1165
1217
 
1166
1218
 
1167
- private fun handleConsentForm() {
1168
- if(mActivity != null) {
1169
- if (consentInformation!!.isConsentFormAvailable) {
1170
- mContext?.let {
1171
- UserMessagingPlatform.loadConsentForm(it,
1172
- { consentForm: ConsentForm ->
1173
- mActivity?.let { it1 ->
1174
- consentForm.show(
1175
- it1
1176
- ) { formError: FormError? ->
1177
- if (formError != null) {
1178
- mActivity!!.runOnUiThread {
1179
- cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + formError.message + "' });")
1180
- }
1181
- }
1182
- }
1183
- }
1184
- },
1185
- { formError: FormError ->
1186
- cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from', { message: '" + formError.message + "' });")
1187
- }
1188
- )
1189
- }
1190
- }
1191
- }
1192
- }
1193
-
1194
-
1195
-
1196
1219
 
1197
1220
  private fun loadBannerAd(adUnitId: String, position: String, size: String) {
1198
1221
  try {
@@ -1210,7 +1233,6 @@ class emiAdmobPlugin : CordovaPlugin() {
1210
1233
  bannerView!!.adUnitId = adUnitId
1211
1234
  bannerView!!.adListener = bannerAdListener
1212
1235
  bannerView!!.loadAd(buildAdRequest())
1213
- // adjustWebViewForBanner(position)
1214
1236
  } else {
1215
1237
  Log.d(TAG, "Banner view layout already exists.")
1216
1238
  }
@@ -1220,28 +1242,6 @@ class emiAdmobPlugin : CordovaPlugin() {
1220
1242
  }
1221
1243
  }
1222
1244
 
1223
- private fun adjustWebViewForBanner(position: String?) {
1224
- val rootView = bannerViewLayout
1225
- val webView = rootView?.findViewById<View>(View.generateViewId())
1226
-
1227
- if (webView != null) {
1228
- when (position) {
1229
- "bottom-center", "bottom-right" -> {
1230
- webView.setPadding(0, 0, 0, bannerView!!.height)
1231
- }
1232
- "top-center", "top-right" -> {
1233
- webView.setPadding(0, bannerView!!.height, 0, 0)
1234
- }
1235
- else -> {
1236
- webView.setPadding(0, 0, 0, 0)
1237
- }
1238
- }
1239
- webView.requestLayout()
1240
- }
1241
- }
1242
-
1243
-
1244
-
1245
1245
 
1246
1246
 
1247
1247
 
@@ -1311,6 +1311,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1311
1311
  if (lock) {
1312
1312
  bannerViewLayout!!.addView(bannerView)
1313
1313
  bannerViewLayout!!.bringToFront()
1314
+ bannerViewLayout!!.requestFocus();
1314
1315
  lock = false
1315
1316
  }
1316
1317
  isBannerPause = 0
@@ -1335,6 +1336,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1335
1336
  if (lock) {
1336
1337
  bannerViewLayout!!.addView(bannerView)
1337
1338
  bannerViewLayout!!.bringToFront()
1339
+ bannerViewLayout!!.requestFocus();
1338
1340
  lock = false
1339
1341
  }
1340
1342
  isBannerShow = true
@@ -1355,16 +1357,32 @@ class emiAdmobPlugin : CordovaPlugin() {
1355
1357
  cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.close');")
1356
1358
  }
1357
1359
 
1358
- override fun onAdFailedToLoad(adError: LoadAdError) {
1359
1360
 
1361
+ override fun onAdFailedToLoad(adError: LoadAdError) {
1360
1362
  val errorData = JSONObject().apply {
1361
- put("responseInfo", adError.responseInfo)
1362
1363
  put("code", adError.code)
1363
1364
  put("message", adError.message)
1364
1365
  put("domain", adError.domain)
1365
1366
  put("cause", adError.cause?.toString() ?: "null")
1367
+
1368
+ val responseId = adError.responseInfo?.responseId.toString()
1369
+ val responseExtras = adError.responseInfo?.responseExtras.toString()
1370
+ val loadedAdapterResponseInfo =
1371
+ adError.responseInfo?.loadedAdapterResponseInfo.toString()
1372
+ val mediationAdapterClassName =
1373
+ adError.responseInfo?.mediationAdapterClassName.toString()
1374
+ val adapterResponses =
1375
+ adError.responseInfo?.adapterResponses.toString()
1376
+
1377
+ put("responseInfoId", responseId)
1378
+ put("responseInfoExtras", responseExtras)
1379
+ put("responseInfoAdapter", loadedAdapterResponseInfo)
1380
+ put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
1381
+ put("responseInfoAdapterResponses", adapterResponses)
1366
1382
  }
1367
1383
 
1384
+ cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
1385
+
1368
1386
  bannerOverlappingToZero()
1369
1387
 
1370
1388
  if (bannerViewLayout != null && bannerView != null) {
@@ -1379,7 +1397,7 @@ class emiAdmobPlugin : CordovaPlugin() {
1379
1397
  }
1380
1398
 
1381
1399
 
1382
- cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
1400
+
1383
1401
  }
1384
1402
 
1385
1403
  override fun onAdImpression() {
@@ -1608,6 +1626,33 @@ class emiAdmobPlugin : CordovaPlugin() {
1608
1626
 
1609
1627
 
1610
1628
 
1629
+ private fun handleConsentForm() {
1630
+ if(mActivity != null) {
1631
+ if (consentInformation!!.isConsentFormAvailable) {
1632
+ mContext?.let {
1633
+ UserMessagingPlatform.loadConsentForm(it,
1634
+ { consentForm: ConsentForm ->
1635
+ mActivity?.let { it1 ->
1636
+ consentForm.show(
1637
+ it1
1638
+ ) { formError: FormError? ->
1639
+ if (formError != null) {
1640
+ mActivity!!.runOnUiThread {
1641
+ cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + formError.message + "' });")
1642
+ }
1643
+ }
1644
+ }
1645
+ }
1646
+ },
1647
+ { formError: FormError ->
1648
+ cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from', { message: '" + formError.message + "' });")
1649
+ }
1650
+ )
1651
+ }
1652
+ }
1653
+ }
1654
+ }
1655
+
1611
1656
 
1612
1657
  private fun setUsingAdManagerRequest(isUsingAdManagerRequest: Boolean) {
1613
1658
  this.isUsingAdManagerRequest = isUsingAdManagerRequest
@@ -2080,9 +2125,7 @@ class emiAdmobPlugin : CordovaPlugin() {
2080
2125
  if (View::class.java.isAssignableFrom(CordovaWebView::class.java)) {
2081
2126
  return cWebView as View?
2082
2127
  }
2083
-
2084
2128
  return mActivity!!.window.decorView.findViewById(View.generateViewId())
2085
- // return mActivity!!.window.decorView.findViewById(R.id.content)
2086
2129
  }
2087
2130
 
2088
2131
  override fun onPause(multitasking: Boolean) {
@@ -2126,4 +2169,6 @@ class emiAdmobPlugin : CordovaPlugin() {
2126
2169
  private const val LAST_ACCESS_SUFFIX = "_last_access"
2127
2170
  private const val EXPIRATION_TIME = 360L * 24 * 60 * 60 * 1000
2128
2171
  }
2129
- }
2172
+ }
2173
+
2174
+
@@ -547,55 +547,6 @@ BOOL isUsingAdManagerRequest = YES;
547
547
 
548
548
 
549
549
 
550
-
551
- /*
552
-
553
- - (void)addBannerConstraints {
554
- self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
555
-
556
- if ([setPosition isEqualToString:@"bottom-center"]) {
557
- [self.viewController.view addConstraints:@[
558
- [NSLayoutConstraint
559
- constraintWithItem:self.bannerView
560
- attribute:NSLayoutAttributeBottom
561
- relatedBy:NSLayoutRelationEqual
562
- toItem:self.viewController.view.safeAreaLayoutGuide
563
- attribute:NSLayoutAttributeBottom
564
- multiplier:1
565
- constant:0],
566
- [NSLayoutConstraint constraintWithItem:self.bannerView
567
- attribute:NSLayoutAttributeCenterX
568
- relatedBy:NSLayoutRelationEqual
569
- toItem:self.viewController.view
570
- attribute:NSLayoutAttributeCenterX
571
- multiplier:1
572
- constant:0]
573
- ]];
574
- } else if ([setPosition isEqualToString:@"top-center"]) {
575
- [self.viewController.view addConstraints:@[
576
- [NSLayoutConstraint
577
- constraintWithItem:self.bannerView
578
- attribute:NSLayoutAttributeTop
579
- relatedBy:NSLayoutRelationEqual
580
- toItem:self.viewController.view.safeAreaLayoutGuide
581
- attribute:NSLayoutAttributeTop
582
- multiplier:1
583
- constant:0],
584
- [NSLayoutConstraint constraintWithItem:self.bannerView
585
- attribute:NSLayoutAttributeCenterX
586
- relatedBy:NSLayoutRelationEqual
587
- toItem:self.viewController.view
588
- attribute:NSLayoutAttributeCenterX
589
- multiplier:1
590
- constant:0]
591
- ]];
592
- }
593
- }
594
-
595
- */
596
-
597
-
598
-
599
550
  - (void)loadBannerAd:(CDVInvokedUrlCommand *)command {
600
551
  CDVPluginResult *pluginResult;
601
552
  NSString *callbackId = command.callbackId;
@@ -611,7 +562,7 @@ BOOL isUsingAdManagerRequest = YES;
611
562
 
612
563
  setPosition = position;
613
564
 
614
- adFormat = 3;
565
+ adFormat = 5;
615
566
 
616
567
  if (adUnitId == nil || [adUnitId length] == 0) {
617
568
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
@@ -623,7 +574,7 @@ BOOL isUsingAdManagerRequest = YES;
623
574
  if (collapsible != nil && [collapsible length] > 0) {
624
575
  isCollapsible = YES;
625
576
  } else {
626
- isCollapsible = YES;
577
+ isCollapsible = NO;
627
578
  }
628
579
 
629
580
  if (autoResize) {
@@ -632,7 +583,7 @@ BOOL isUsingAdManagerRequest = YES;
632
583
 
633
584
  [self setAdRequest];
634
585
 
635
- if (adFormat == 3) {
586
+ if (adFormat == 5) {
636
587
  dispatch_async(dispatch_get_main_queue(), ^{
637
588
  UIView *parentView = [self.webView superview];
638
589
  CGRect frame = self.bannerView.frame;
@@ -936,6 +887,7 @@ BOOL isUsingAdManagerRequest = YES;
936
887
  [self.appOpenAd canPresentFromRootViewController:self.viewController
937
888
  error:nil]) {
938
889
  [self.appOpenAd presentFromRootViewController:self.viewController];
890
+ adFormat = 1;
939
891
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
940
892
  } else {
941
893
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
@@ -1006,9 +958,9 @@ BOOL isUsingAdManagerRequest = YES;
1006
958
  NSDictionary *errorData = @{@"error": presentError.localizedDescription ?: @"Unknown error"};
1007
959
  NSData *errorJsonData = [NSJSONSerialization dataWithJSONObject:errorData options:0 error:nil];
1008
960
  NSString *errorJsonString = [[NSString alloc] initWithData:errorJsonData encoding:NSUTF8StringEncoding];
1009
-
1010
961
  [self fireEvent:@"" event:@"on.interstitial.failed.show" withData:errorJsonString];
1011
962
  }
963
+ adFormat = 2;
1012
964
  }
1013
965
 
1014
966
 
@@ -1063,6 +1015,7 @@ BOOL isUsingAdManagerRequest = YES;
1063
1015
  NSError *presentError = nil;
1064
1016
  if (self.interstitial && [self.interstitial canPresentFromRootViewController:self.viewController error:&presentError]) {
1065
1017
  [self.interstitial presentFromRootViewController:self.viewController];
1018
+ adFormat = 2;
1066
1019
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1067
1020
  } else {
1068
1021
  // Send show error to event
@@ -1144,9 +1097,9 @@ BOOL isUsingAdManagerRequest = YES;
1144
1097
  };
1145
1098
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1146
1099
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
1147
-
1148
- [self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
1100
+ adFormat = 4;
1149
1101
  isAdSkip = 2;
1102
+ [self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
1150
1103
  NSLog(@"Reward received with currency %@, amount %ld", reward.type, [reward.amount longValue]);
1151
1104
  }];
1152
1105
  } else {
@@ -1219,9 +1172,9 @@ BOOL isUsingAdManagerRequest = YES;
1219
1172
  };
1220
1173
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1221
1174
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
1222
-
1223
- [self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
1224
1175
  isAdSkip = 2;
1176
+ adFormat = 4;
1177
+ [self fireEvent:@"" event:@"on.rewardedInt.userEarnedReward" withData:rewardJsonString];
1225
1178
  NSLog(@"Reward received with currency %@, amount %ld", reward.type, [reward.amount longValue]);
1226
1179
  }];
1227
1180
 
@@ -1260,7 +1213,6 @@ BOOL isUsingAdManagerRequest = YES;
1260
1213
  }
1261
1214
 
1262
1215
  self.rewardedAd = ad;
1263
-
1264
1216
  isAdSkip = 0;
1265
1217
  self.rewardedAd.fullScreenContentDelegate = self;
1266
1218
  [self fireEvent:@"" event:@"on.rewarded.loaded" withData:nil];
@@ -1295,16 +1247,15 @@ BOOL isUsingAdManagerRequest = YES;
1295
1247
  if ([self.rewardedAd canPresentFromRootViewController:self.viewController error:&presentError]) {
1296
1248
  [self.rewardedAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
1297
1249
  GADAdReward *reward = self.rewardedAd.adReward;
1298
-
1250
+ adFormat = 3;
1299
1251
  NSDictionary *rewardData = @{
1300
1252
  @"rewardType": reward.type,
1301
1253
  @"rewardAmount": [reward.amount stringValue]
1302
1254
  };
1303
1255
  NSData *rewardJsonData = [NSJSONSerialization dataWithJSONObject:rewardData options:0 error:nil];
1304
1256
  NSString *rewardJsonString = [[NSString alloc] initWithData:rewardJsonData encoding:NSUTF8StringEncoding];
1305
-
1306
- [self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:rewardJsonString];
1307
1257
  isAdSkip = 2;
1258
+ [self fireEvent:@"" event:@"on.reward.userEarnedReward" withData:rewardJsonString];
1308
1259
 
1309
1260
  }];
1310
1261
  } else {
@@ -1384,7 +1335,7 @@ BOOL isUsingAdManagerRequest = YES;
1384
1335
  }
1385
1336
 
1386
1337
  isAdSkip = 2;
1387
-
1338
+ adFormat = 3;
1388
1339
 
1389
1340
  NSLog(@"Reward received with currency %@, amount %lf", reward.type, [reward.amount doubleValue]);
1390
1341
  }];
@@ -1531,9 +1482,6 @@ BOOL isUsingAdManagerRequest = YES;
1531
1482
 
1532
1483
 
1533
1484
 
1534
-
1535
-
1536
-
1537
1485
  if (isResponseInfo) {
1538
1486
  GADResponseInfo *responseInfo = self.bannerView.responseInfo;
1539
1487
  NSMutableArray *adNetworkInfoArray = [NSMutableArray array];
@@ -1609,15 +1557,19 @@ BOOL isUsingAdManagerRequest = YES;
1609
1557
 
1610
1558
  - (void)adWillPresentFullScreenContent:(id)ad {
1611
1559
  if (adFormat == 1) {
1560
+ adFormat = 1;
1612
1561
  [self fireEvent:@"" event:@"on.appOpenAd.show" withData:nil];
1613
1562
  } else if (adFormat == 2) {
1563
+ adFormat = 2;
1614
1564
  [self fireEvent:@"" event:@"on.interstitial.show" withData:nil];
1615
1565
  [self fireEvent:@"" event:@"onPresentAd" withData:nil];
1616
1566
  } else if (adFormat == 3) {
1567
+ adFormat = 3;
1617
1568
  [self fireEvent:@"" event:@"on.rewarded.show" withData:nil];
1618
1569
  isAdSkip = 1;
1619
1570
  } else if (adFormat == 4) {
1620
1571
  isAdSkip = 1;
1572
+ adFormat = 4;
1621
1573
  [self fireEvent:@"" event:@"on.rewardedInt.showed" withData:nil];
1622
1574
  }
1623
1575
  }
@@ -1650,15 +1602,17 @@ BOOL isUsingAdManagerRequest = YES;
1650
1602
  } else if (adFormat == 2) {
1651
1603
  [self fireEvent:@"" event:@"on.interstitial.dismissed" withData:nil];
1652
1604
  } else if (adFormat == 3) {
1653
- [self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil];
1654
1605
  if (isAdSkip != 2) {
1655
1606
  [self fireEvent:@"" event:@"on.rewarded.ad.skip" withData:nil];
1607
+ } else {
1608
+ [self fireEvent:@"" event:@"on.rewarded.dismissed" withData:nil];
1656
1609
  }
1657
1610
  } else if (adFormat == 4) {
1658
1611
  if (isAdSkip != 2) {
1659
1612
  [self fireEvent:@"" event:@"on.rewardedInt.ad.skip" withData:nil];
1613
+ } else {
1614
+ [self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
1660
1615
  }
1661
- [self fireEvent:@"" event:@"on.rewardedInt.dismissed" withData:nil];
1662
1616
  }
1663
1617
  }
1664
1618