emi-indo-cordova-plugin-admob 2.0.0 → 2.0.2
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 +1 -0
- package/package.json +1 -1
- package/plugin.xml +2 -2
- package/src/android/emiAdmobPlugin.kt +288 -360
@@ -34,7 +34,6 @@ import com.google.android.gms.ads.RequestConfiguration.PublisherPrivacyPersonali
|
|
34
34
|
import com.google.android.gms.ads.admanager.AdManagerAdRequest
|
35
35
|
import com.google.android.gms.ads.appopen.AppOpenAd
|
36
36
|
import com.google.android.gms.ads.appopen.AppOpenAd.AppOpenAdLoadCallback
|
37
|
-
import com.google.android.gms.ads.initialization.InitializationStatus
|
38
37
|
import com.google.android.gms.ads.interstitial.InterstitialAd
|
39
38
|
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback
|
40
39
|
import com.google.android.gms.ads.rewarded.RewardItem
|
@@ -48,6 +47,9 @@ import com.google.android.ump.ConsentInformation
|
|
48
47
|
import com.google.android.ump.ConsentRequestParameters
|
49
48
|
import com.google.android.ump.FormError
|
50
49
|
import com.google.android.ump.UserMessagingPlatform
|
50
|
+
import kotlinx.coroutines.CoroutineScope
|
51
|
+
import kotlinx.coroutines.Dispatchers
|
52
|
+
import kotlinx.coroutines.launch
|
51
53
|
import org.apache.cordova.CallbackContext
|
52
54
|
import org.apache.cordova.CordovaInterface
|
53
55
|
import org.apache.cordova.CordovaPlugin
|
@@ -109,8 +111,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
109
111
|
private var isCollapsible: Boolean = false
|
110
112
|
var lock: Boolean = true
|
111
113
|
private var setDebugGeography: Boolean = false
|
112
|
-
|
113
|
-
private var mContext: Context? = null
|
114
|
+
|
114
115
|
private var mInterstitialAd: InterstitialAd? = null
|
115
116
|
private var appOpenAd: AppOpenAd? = null
|
116
117
|
private var isOrientation: Int = 1
|
@@ -143,55 +144,64 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
143
144
|
|
144
145
|
private var isCustomConsentManager = false
|
145
146
|
|
147
|
+
private var mActivity: Activity? = null
|
148
|
+
private var mContext: Context? = null
|
149
|
+
|
146
150
|
|
147
151
|
override fun initialize(cordova: CordovaInterface, webView: CordovaWebView) {
|
148
152
|
super.initialize(cordova, webView)
|
153
|
+
|
149
154
|
cWebView = webView
|
150
|
-
mActivity =
|
151
|
-
|
152
|
-
|
153
|
-
}
|
155
|
+
mActivity = cordova.activity
|
156
|
+
|
157
|
+
if (mActivity != null) {
|
154
158
|
|
155
|
-
|
159
|
+
mContext = mActivity?.applicationContext
|
156
160
|
|
161
|
+
mPreferences = mContext?.let { PreferenceManager.getDefaultSharedPreferences(it) }
|
162
|
+
|
163
|
+
} else {
|
164
|
+
Log.e("PluginCordova", "Activity is null during initialization")
|
165
|
+
}
|
157
166
|
}
|
158
167
|
|
159
168
|
|
160
169
|
|
170
|
+
|
161
171
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
162
172
|
super.onConfigurationChanged(newConfig)
|
163
173
|
val orientation = newConfig.orientation
|
164
174
|
if (orientation != isOrientation) {
|
165
|
-
cWebView
|
175
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.screen.rotated');")
|
166
176
|
isOrientation = orientation
|
167
177
|
if (this.isAutoResize) {
|
168
178
|
if(mActivity != null) {
|
169
|
-
mActivity
|
179
|
+
mActivity?.runOnUiThread {
|
170
180
|
try {
|
171
181
|
bannerOverlappingToZero()
|
172
182
|
if (bannerViewLayout != null && bannerView != null) {
|
173
|
-
val parentView = bannerViewLayout
|
183
|
+
val parentView = bannerViewLayout?.parent as ViewGroup
|
174
184
|
parentView.removeView(bannerViewLayout)
|
175
185
|
bannerViewLayout = FrameLayout(mActivity!!)
|
176
186
|
val params = FrameLayout.LayoutParams(
|
177
187
|
FrameLayout.LayoutParams.MATCH_PARENT,
|
178
188
|
FrameLayout.LayoutParams.WRAP_CONTENT
|
179
189
|
)
|
180
|
-
val decorView = mActivity
|
190
|
+
val decorView = mActivity?.window?.decorView as ViewGroup
|
181
191
|
decorView.addView(bannerViewLayout, params)
|
182
192
|
bannerView = AdView(mActivity!!)
|
183
193
|
setBannerPosition(this.isPosition)
|
184
|
-
|
185
|
-
bannerView
|
186
|
-
bannerView
|
187
|
-
bannerView
|
188
|
-
bannerViewLayout
|
189
|
-
bannerViewLayout
|
190
|
-
bannerViewLayout
|
194
|
+
setBannerSize(this.isSize)
|
195
|
+
bannerView?.adUnitId = bannerAdUnitId!!
|
196
|
+
bannerView?.adListener = bannerAdListener
|
197
|
+
bannerView?.loadAd(buildAdRequest())
|
198
|
+
bannerViewLayout?.addView(bannerView)
|
199
|
+
bannerViewLayout?.bringToFront()
|
200
|
+
bannerViewLayout?.requestFocus();
|
191
201
|
bannerOverlappingToZero()
|
192
202
|
}
|
193
203
|
} catch (e: Exception) {
|
194
|
-
PUBLIC_CALLBACKS
|
204
|
+
PUBLIC_CALLBACKS?.error("Error adjusting banner size: " + e.message)
|
195
205
|
}
|
196
206
|
}
|
197
207
|
}
|
@@ -202,16 +212,16 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
202
212
|
if (isOverlapping) {
|
203
213
|
bannerOverlapping()
|
204
214
|
}
|
205
|
-
cWebView
|
215
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.orientation.portrait');")
|
206
216
|
}
|
207
217
|
Configuration.ORIENTATION_LANDSCAPE -> {
|
208
218
|
if (isOverlapping) {
|
209
219
|
bannerOverlapping()
|
210
220
|
}
|
211
|
-
cWebView
|
221
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.orientation.landscape');")
|
212
222
|
}
|
213
223
|
Configuration.ORIENTATION_UNDEFINED -> {
|
214
|
-
cWebView
|
224
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.orientation.undefined');")
|
215
225
|
}
|
216
226
|
|
217
227
|
|
@@ -409,7 +419,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
409
419
|
} else if (action == "loadAppOpenAd") {
|
410
420
|
val options = args.getJSONObject(0)
|
411
421
|
if (mActivity != null) {
|
412
|
-
mActivity
|
422
|
+
mActivity?.runOnUiThread {
|
413
423
|
val adUnitId = options.optString("adUnitId")
|
414
424
|
val autoShow = options.optBoolean("autoShow")
|
415
425
|
try {
|
@@ -426,18 +436,18 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
426
436
|
openAutoShow()
|
427
437
|
}
|
428
438
|
|
429
|
-
cWebView
|
439
|
+
cWebView?.loadUrl(
|
430
440
|
"javascript:cordova.fireDocumentEvent('on.appOpenAd.loaded');"
|
431
441
|
)
|
432
442
|
|
433
443
|
appOpenAdLoadCallback()
|
434
444
|
|
435
|
-
appOpenAd
|
445
|
+
appOpenAd?.onPaidEventListener =
|
436
446
|
OnPaidEventListener { adValue: AdValue ->
|
437
|
-
val valueMicros = adValue.valueMicros
|
438
|
-
val currencyCode = adValue.currencyCode
|
439
|
-
val precision = adValue.precisionType
|
440
|
-
val appOpenAdAdUnitId = appOpenAd
|
447
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
448
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
449
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
450
|
+
val appOpenAdAdUnitId = appOpenAd?.adUnitId ?: "null"
|
441
451
|
|
442
452
|
val result = JSONObject()
|
443
453
|
try {
|
@@ -456,26 +466,14 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
456
466
|
|
457
467
|
if (isResponseInfo) {
|
458
468
|
val result = JSONObject()
|
459
|
-
val responseInfo =
|
469
|
+
val responseInfo = appOpenAd?.responseInfo
|
460
470
|
try {
|
461
|
-
result.put(
|
462
|
-
|
463
|
-
|
464
|
-
)
|
465
|
-
result.put(
|
466
|
-
"getAdapterResponses",
|
467
|
-
responseInfo.adapterResponses.toString()
|
468
|
-
)
|
469
|
-
result.put(
|
470
|
-
"getResponseExtras",
|
471
|
-
responseInfo.responseExtras.toString()
|
472
|
-
)
|
473
|
-
result.put(
|
474
|
-
"getMediationAdapterClassName",
|
475
|
-
responseInfo.mediationAdapterClassName.toString()
|
476
|
-
)
|
471
|
+
result.put("getResponseId", responseInfo?.responseId.toString())
|
472
|
+
result.put("getAdapterResponses", responseInfo?.adapterResponses.toString())
|
473
|
+
result.put("getResponseExtras", responseInfo?.responseExtras.toString())
|
474
|
+
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName.toString())
|
477
475
|
result.put("getBundleExtra", mBundleExtra.toString())
|
478
|
-
cWebView
|
476
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.responseInfo', ${result})")
|
479
477
|
} catch (e: JSONException) {
|
480
478
|
callbackContext.error(e.message)
|
481
479
|
}
|
@@ -489,14 +487,14 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
489
487
|
private fun openAutoShow() {
|
490
488
|
try {
|
491
489
|
if (mActivity != null && isAppOpenAdShow && appOpenAd != null) {
|
492
|
-
mActivity
|
493
|
-
appOpenAd
|
490
|
+
mActivity?.runOnUiThread {
|
491
|
+
appOpenAd?.show(
|
494
492
|
mActivity!!
|
495
|
-
)
|
493
|
+
) ?: callbackContext.error("Failed to show App Open Ad")
|
496
494
|
}
|
497
495
|
}
|
498
496
|
} catch (e: Exception) {
|
499
|
-
PUBLIC_CALLBACKS
|
497
|
+
PUBLIC_CALLBACKS?.error(e.toString())
|
500
498
|
}
|
501
499
|
}
|
502
500
|
|
@@ -508,24 +506,16 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
508
506
|
put("domain", loadAdError.domain)
|
509
507
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
510
508
|
|
511
|
-
val responseId =
|
512
|
-
|
513
|
-
val
|
514
|
-
|
515
|
-
val
|
516
|
-
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
517
|
-
val mediationAdapterClassName =
|
518
|
-
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
519
|
-
val adapterResponses =
|
520
|
-
loadAdError.responseInfo?.adapterResponses.toString()
|
509
|
+
val responseId = loadAdError.responseInfo?.responseId.toString()
|
510
|
+
val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
|
511
|
+
val loadedAdapterResponseInfo = loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
512
|
+
val mediationAdapterClassName = loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
513
|
+
val adapterResponses = loadAdError.responseInfo?.adapterResponses.toString()
|
521
514
|
|
522
515
|
put("responseInfoId", responseId)
|
523
516
|
put("responseInfoExtras", responseExtras)
|
524
517
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
525
|
-
put(
|
526
|
-
"responseInfoMediationAdapterClassName",
|
527
|
-
mediationAdapterClassName
|
528
|
-
)
|
518
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
529
519
|
put("responseInfoAdapterResponses", adapterResponses)
|
530
520
|
}
|
531
521
|
cWebView?.loadUrl(
|
@@ -544,7 +534,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
544
534
|
|
545
535
|
try {
|
546
536
|
if (mActivity != null && isAppOpenAdShow && appOpenAd != null) {
|
547
|
-
mActivity
|
537
|
+
mActivity?.runOnUiThread { appOpenAd?.show(mActivity!!) ?: callbackContext.error("Failed to show App Open Ad") }
|
548
538
|
appOpenAdLoadCallback()
|
549
539
|
} else {
|
550
540
|
callbackContext.error("The App Open Ad wasn't ready yet")
|
@@ -557,7 +547,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
557
547
|
} else if (action == "loadInterstitialAd") {
|
558
548
|
val options = args.getJSONObject(0)
|
559
549
|
if (mActivity != null) {
|
560
|
-
mActivity
|
550
|
+
mActivity?.runOnUiThread {
|
561
551
|
val adUnitId = options.optString("adUnitId")
|
562
552
|
val autoShow = options.optBoolean("autoShow")
|
563
553
|
try {
|
@@ -573,7 +563,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
573
563
|
isIntAutoShow
|
574
564
|
}
|
575
565
|
|
576
|
-
cWebView
|
566
|
+
cWebView?.loadUrl(
|
577
567
|
"javascript:cordova.fireDocumentEvent('on.interstitial.loaded');"
|
578
568
|
)
|
579
569
|
|
@@ -581,21 +571,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
581
571
|
|
582
572
|
if (isResponseInfo) {
|
583
573
|
val result = JSONObject()
|
584
|
-
val responseInfo = mInterstitialAd
|
574
|
+
val responseInfo = mInterstitialAd?.responseInfo
|
585
575
|
try {
|
586
|
-
result.put("getResponseId", responseInfo
|
587
|
-
result.put(
|
588
|
-
|
589
|
-
|
590
|
-
)
|
591
|
-
result.put(
|
592
|
-
"getResponseExtras",
|
593
|
-
responseInfo.responseExtras
|
594
|
-
)
|
595
|
-
result.put(
|
596
|
-
"getMediationAdapterClassName",
|
597
|
-
responseInfo.mediationAdapterClassName
|
598
|
-
)
|
576
|
+
result.put("getResponseId", responseInfo?.responseId)
|
577
|
+
result.put("getAdapterResponses", responseInfo?.adapterResponses)
|
578
|
+
result.put("getResponseExtras", responseInfo?.responseExtras)
|
579
|
+
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName)
|
599
580
|
result.put("getBundleExtra", mBundleExtra.toString())
|
600
581
|
cWebView!!.loadUrl(
|
601
582
|
"javascript:cordova.fireDocumentEvent('on.interstitialAd.responseInfo', ${result});"
|
@@ -605,19 +586,19 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
605
586
|
callbackContext.error(e.message)
|
606
587
|
}
|
607
588
|
}
|
608
|
-
mInterstitialAd
|
589
|
+
mInterstitialAd?.onPaidEventListener =
|
609
590
|
OnPaidEventListener { adValue: AdValue ->
|
610
|
-
val valueMicros = adValue.valueMicros
|
611
|
-
val currencyCode = adValue.currencyCode
|
612
|
-
val precision = adValue.precisionType
|
613
|
-
val interstitialAdUnitId = mInterstitialAd
|
591
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
592
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
593
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
594
|
+
val interstitialAdUnitId = mInterstitialAd?.adUnitId ?: "null"
|
614
595
|
val result = JSONObject()
|
615
596
|
try {
|
616
597
|
result.put("micros", valueMicros)
|
617
598
|
result.put("currency", currencyCode)
|
618
599
|
result.put("precision", precision)
|
619
600
|
result.put("adUnitId", interstitialAdUnitId)
|
620
|
-
cWebView
|
601
|
+
cWebView?.loadUrl(
|
621
602
|
"javascript:cordova.fireDocumentEvent('on.interstitial.revenue', ${result});"
|
622
603
|
)
|
623
604
|
|
@@ -631,10 +612,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
631
612
|
private val isIntAutoShow: Unit
|
632
613
|
get() {
|
633
614
|
if (mActivity != null && isInterstitialLoad && mInterstitialAd != null) {
|
634
|
-
mActivity
|
635
|
-
mInterstitialAd
|
615
|
+
mActivity?.runOnUiThread {
|
616
|
+
mInterstitialAd?.show(
|
636
617
|
mActivity!!
|
637
|
-
)
|
618
|
+
) ?: callbackContext.error("Failed to show Interstitial Ad")
|
638
619
|
}
|
639
620
|
}
|
640
621
|
}
|
@@ -649,29 +630,20 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
649
630
|
put("domain", loadAdError.domain)
|
650
631
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
651
632
|
|
652
|
-
val responseId =
|
653
|
-
|
654
|
-
val
|
655
|
-
|
656
|
-
val
|
657
|
-
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
658
|
-
val mediationAdapterClassName =
|
659
|
-
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
660
|
-
val adapterResponses =
|
661
|
-
loadAdError.responseInfo?.adapterResponses.toString()
|
633
|
+
val responseId = loadAdError.responseInfo?.responseId.toString()
|
634
|
+
val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
|
635
|
+
val loadedAdapterResponseInfo = loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
636
|
+
val mediationAdapterClassName = loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
637
|
+
val adapterResponses = loadAdError.responseInfo?.adapterResponses.toString()
|
662
638
|
|
663
639
|
put("responseInfoId", responseId)
|
664
640
|
put("responseInfoExtras", responseExtras)
|
665
641
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
666
|
-
put(
|
667
|
-
"responseInfoMediationAdapterClassName",
|
668
|
-
mediationAdapterClassName
|
669
|
-
)
|
642
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
670
643
|
put("responseInfoAdapterResponses", adapterResponses)
|
671
644
|
}
|
672
645
|
|
673
|
-
|
674
|
-
cWebView!!.loadUrl(
|
646
|
+
cWebView?.loadUrl(
|
675
647
|
"javascript:cordova.fireDocumentEvent('on.interstitial.failed.load', ${errorData});"
|
676
648
|
)
|
677
649
|
|
@@ -686,7 +658,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
686
658
|
} else if (action == "showInterstitialAd") {
|
687
659
|
|
688
660
|
if (mActivity != null && isInterstitialLoad && mInterstitialAd != null) {
|
689
|
-
mActivity
|
661
|
+
mActivity?.runOnUiThread { mInterstitialAd?.show(mActivity!!) ?: callbackContext.error("Failed to show Interstitial Ad") }
|
690
662
|
interstitialAdLoadCallback()
|
691
663
|
} else {
|
692
664
|
callbackContext.error("The Interstitial ad wasn't ready yet")
|
@@ -695,7 +667,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
695
667
|
} else if (action == "loadRewardedAd") {
|
696
668
|
val options = args.getJSONObject(0)
|
697
669
|
if (mActivity != null) {
|
698
|
-
mActivity
|
670
|
+
mActivity?.runOnUiThread {
|
699
671
|
val adUnitId = options.optString("adUnitId")
|
700
672
|
val autoShow = options.optBoolean("autoShow")
|
701
673
|
try {
|
@@ -714,30 +686,21 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
714
686
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
715
687
|
|
716
688
|
|
717
|
-
val responseId =
|
718
|
-
|
719
|
-
val
|
720
|
-
|
721
|
-
val
|
722
|
-
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
723
|
-
val mediationAdapterClassName =
|
724
|
-
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
725
|
-
val adapterResponses =
|
726
|
-
loadAdError.responseInfo?.adapterResponses.toString()
|
689
|
+
val responseId = loadAdError.responseInfo?.responseId.toString()
|
690
|
+
val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
|
691
|
+
val loadedAdapterResponseInfo = loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
692
|
+
val mediationAdapterClassName = loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
693
|
+
val adapterResponses = loadAdError.responseInfo?.adapterResponses.toString()
|
727
694
|
|
728
695
|
put("responseInfoId", responseId)
|
729
696
|
put("responseInfoExtras", responseExtras)
|
730
697
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
731
|
-
put(
|
732
|
-
"responseInfoMediationAdapterClassName",
|
733
|
-
mediationAdapterClassName
|
734
|
-
)
|
698
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
735
699
|
put("responseInfoAdapterResponses", adapterResponses)
|
736
700
|
|
737
|
-
|
738
701
|
}
|
739
702
|
|
740
|
-
cWebView
|
703
|
+
cWebView?.loadUrl(
|
741
704
|
"javascript:cordova.fireDocumentEvent('on.rewarded.failed.load', ${errorData});"
|
742
705
|
)
|
743
706
|
|
@@ -754,23 +717,23 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
754
717
|
|
755
718
|
rewardedAdLoadCallback()
|
756
719
|
|
757
|
-
cWebView
|
720
|
+
cWebView?.loadUrl(
|
758
721
|
"javascript:cordova.fireDocumentEvent('on.rewarded.loaded');"
|
759
722
|
)
|
760
723
|
|
761
|
-
rewardedAd
|
724
|
+
rewardedAd?.onPaidEventListener =
|
762
725
|
OnPaidEventListener { adValue: AdValue ->
|
763
|
-
val valueMicros = adValue.valueMicros
|
764
|
-
val currencyCode = adValue.currencyCode
|
765
|
-
val precision = adValue.precisionType
|
766
|
-
val rewardedAdAdUnitId = rewardedAd
|
726
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
727
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
728
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
729
|
+
val rewardedAdAdUnitId = rewardedAd?.adUnitId ?: "null"
|
767
730
|
val result = JSONObject()
|
768
731
|
try {
|
769
732
|
result.put("micros", valueMicros)
|
770
733
|
result.put("currency", currencyCode)
|
771
734
|
result.put("precision", precision)
|
772
735
|
result.put("adUnitId", rewardedAdAdUnitId)
|
773
|
-
cWebView
|
736
|
+
cWebView?.loadUrl(
|
774
737
|
"javascript:cordova.fireDocumentEvent('on.rewarded.revenue', ${result});"
|
775
738
|
)
|
776
739
|
} catch (e: JSONException) {
|
@@ -783,21 +746,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
783
746
|
|
784
747
|
if (isResponseInfo) {
|
785
748
|
val result = JSONObject()
|
786
|
-
val responseInfo =
|
749
|
+
val responseInfo = rewardedAd?.responseInfo
|
787
750
|
try {
|
788
|
-
result.put("getResponseId", responseInfo
|
789
|
-
result.put(
|
790
|
-
|
791
|
-
|
792
|
-
)
|
793
|
-
result.put(
|
794
|
-
"getResponseExtras",
|
795
|
-
responseInfo.responseExtras
|
796
|
-
)
|
797
|
-
result.put(
|
798
|
-
"getMediationAdapterClassName",
|
799
|
-
responseInfo.mediationAdapterClassName
|
800
|
-
)
|
751
|
+
result.put("getResponseId", responseInfo?.responseId)
|
752
|
+
result.put("getAdapterResponses", responseInfo?.adapterResponses)
|
753
|
+
result.put("getResponseExtras", responseInfo?.responseExtras)
|
754
|
+
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName)
|
801
755
|
result.put("getBundleExtra", mBundleExtra.toString())
|
802
756
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAd.responseInfo', ${result})")
|
803
757
|
} catch (e: JSONException) {
|
@@ -811,10 +765,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
811
765
|
private val isRewardedAutoShow: Unit
|
812
766
|
get() {
|
813
767
|
if (mActivity != null) {
|
814
|
-
mActivity
|
768
|
+
mActivity?.runOnUiThread {
|
815
769
|
if (isRewardedLoad && rewardedAd != null) {
|
816
770
|
isAdSkip = 1
|
817
|
-
rewardedAd
|
771
|
+
rewardedAd?.show(mActivity!!) { rewardItem: RewardItem ->
|
818
772
|
isAdSkip = 2
|
819
773
|
val rewardAmount = rewardItem.amount
|
820
774
|
val rewardType = rewardItem.type
|
@@ -822,7 +776,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
822
776
|
try {
|
823
777
|
result.put("rewardType", rewardType)
|
824
778
|
result.put("rewardAmount", rewardAmount)
|
825
|
-
cWebView
|
779
|
+
cWebView?.loadUrl(
|
826
780
|
"javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward', ${result});"
|
827
781
|
)
|
828
782
|
} catch (e: JSONException) {
|
@@ -843,9 +797,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
843
797
|
return true
|
844
798
|
} else if (action == "showRewardedAd") {
|
845
799
|
if (mActivity != null && isRewardedLoad && rewardedAd != null) {
|
846
|
-
mActivity
|
800
|
+
mActivity?.runOnUiThread {
|
847
801
|
isAdSkip = 1
|
848
|
-
rewardedAd
|
802
|
+
rewardedAd?.show(mActivity!!) { rewardItem: RewardItem ->
|
849
803
|
isAdSkip = 2
|
850
804
|
val rewardAmount = rewardItem.amount
|
851
805
|
val rewardType = rewardItem.type
|
@@ -853,7 +807,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
853
807
|
try {
|
854
808
|
result.put("rewardType", rewardType)
|
855
809
|
result.put("rewardAmount", rewardAmount)
|
856
|
-
cWebView
|
810
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward', ${result});")
|
857
811
|
} catch (e: JSONException) {
|
858
812
|
callbackContext.error(e.message)
|
859
813
|
}
|
@@ -870,7 +824,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
870
824
|
} else if (action == "loadRewardedInterstitialAd") {
|
871
825
|
val options = args.getJSONObject(0)
|
872
826
|
if (mActivity != null) {
|
873
|
-
mActivity
|
827
|
+
mActivity?.runOnUiThread {
|
874
828
|
val adUnitId = options.optString("adUnitId")
|
875
829
|
val autoShow = options.optBoolean("autoShow")
|
876
830
|
try {
|
@@ -883,7 +837,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
883
837
|
isRewardedInterstitialLoad = true
|
884
838
|
isAdSkip = 0
|
885
839
|
|
886
|
-
cWebView
|
840
|
+
cWebView?.loadUrl(
|
887
841
|
"javascript:cordova.fireDocumentEvent('on.rewardedInt.loaded');"
|
888
842
|
)
|
889
843
|
|
@@ -893,13 +847,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
893
847
|
|
894
848
|
rewardedInterstitialAdLoadCallback()
|
895
849
|
|
896
|
-
rewardedInterstitialAd
|
850
|
+
rewardedInterstitialAd?.onPaidEventListener =
|
897
851
|
OnPaidEventListener { adValue: AdValue ->
|
898
|
-
val valueMicros = adValue.valueMicros
|
899
|
-
val currencyCode = adValue.currencyCode
|
900
|
-
val precision = adValue.precisionType
|
901
|
-
val rewardedIntAdUnitId =
|
902
|
-
rewardedInterstitialAd!!.adUnitId
|
852
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
853
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
854
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
855
|
+
val rewardedIntAdUnitId = rewardedInterstitialAd?.adUnitId ?: "null"
|
903
856
|
val result = JSONObject()
|
904
857
|
try {
|
905
858
|
result.put("micros", valueMicros)
|
@@ -918,23 +871,14 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
918
871
|
|
919
872
|
if (isResponseInfo) {
|
920
873
|
val result = JSONObject()
|
921
|
-
val responseInfo = rewardedInterstitialAd
|
874
|
+
val responseInfo = rewardedInterstitialAd?.responseInfo
|
922
875
|
try {
|
923
|
-
result.put("getResponseId", responseInfo
|
924
|
-
result.put(
|
925
|
-
|
926
|
-
|
927
|
-
)
|
928
|
-
result.put(
|
929
|
-
"getResponseExtras",
|
930
|
-
responseInfo.responseExtras
|
931
|
-
)
|
932
|
-
result.put(
|
933
|
-
"getMediationAdapterClassName",
|
934
|
-
responseInfo.mediationAdapterClassName
|
935
|
-
)
|
876
|
+
result.put("getResponseId", responseInfo?.responseId)
|
877
|
+
result.put("getAdapterResponses", responseInfo?.adapterResponses)
|
878
|
+
result.put("getResponseExtras", responseInfo?.responseExtras)
|
879
|
+
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName)
|
936
880
|
result.put("getBundleExtra", mBundleExtra.toString())
|
937
|
-
cWebView
|
881
|
+
cWebView?.loadUrl(
|
938
882
|
"javascript:cordova.fireDocumentEvent('on.rewardedIntAd.responseInfo', ${result});"
|
939
883
|
)
|
940
884
|
} catch (e: JSONException) {
|
@@ -949,10 +893,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
949
893
|
private val isRIntAutoShow: Unit
|
950
894
|
get() {
|
951
895
|
if (mActivity !== null) {
|
952
|
-
mActivity
|
896
|
+
mActivity?.runOnUiThread {
|
953
897
|
if (isRewardedInterstitialLoad && rewardedInterstitialAd != null) {
|
954
898
|
isAdSkip = 1
|
955
|
-
rewardedInterstitialAd
|
899
|
+
rewardedInterstitialAd?.show(mActivity!!) { rewardItem: RewardItem ->
|
956
900
|
isAdSkip = 2
|
957
901
|
val rewardAmount = rewardItem.amount
|
958
902
|
val rewardType = rewardItem.type
|
@@ -960,7 +904,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
960
904
|
try {
|
961
905
|
result.put("rewardType", rewardType)
|
962
906
|
result.put("rewardAmount", rewardAmount)
|
963
|
-
cWebView
|
907
|
+
cWebView?.loadUrl(
|
964
908
|
"javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward', ${result});"
|
965
909
|
)
|
966
910
|
} catch (e: JSONException) {
|
@@ -982,27 +926,19 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
982
926
|
put("domain", loadAdError.domain)
|
983
927
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
984
928
|
|
985
|
-
val responseId =
|
986
|
-
|
987
|
-
val
|
988
|
-
|
989
|
-
val
|
990
|
-
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
991
|
-
val mediationAdapterClassName =
|
992
|
-
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
993
|
-
val adapterResponses =
|
994
|
-
loadAdError.responseInfo?.adapterResponses.toString()
|
929
|
+
val responseId = loadAdError.responseInfo?.responseId.toString()
|
930
|
+
val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
|
931
|
+
val loadedAdapterResponseInfo = loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
932
|
+
val mediationAdapterClassName = loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
933
|
+
val adapterResponses = loadAdError.responseInfo?.adapterResponses.toString()
|
995
934
|
|
996
935
|
put("responseInfoId", responseId)
|
997
936
|
put("responseInfoExtras", responseExtras)
|
998
937
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
999
|
-
put(
|
1000
|
-
"responseInfoMediationAdapterClassName",
|
1001
|
-
mediationAdapterClassName
|
1002
|
-
)
|
938
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
1003
939
|
put("responseInfoAdapterResponses", adapterResponses)
|
1004
940
|
}
|
1005
|
-
cWebView
|
941
|
+
cWebView?.loadUrl(
|
1006
942
|
"javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load', ${errorData});"
|
1007
943
|
)
|
1008
944
|
|
@@ -1016,10 +952,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1016
952
|
return true
|
1017
953
|
} else if (action == "showRewardedInterstitialAd") {
|
1018
954
|
if (mActivity != null) {
|
1019
|
-
mActivity
|
955
|
+
mActivity?.runOnUiThread {
|
1020
956
|
if (isRewardedInterstitialLoad && rewardedInterstitialAd != null) {
|
1021
957
|
isAdSkip = 1
|
1022
|
-
rewardedInterstitialAd
|
958
|
+
rewardedInterstitialAd?.show(mActivity!!) { rewardItem: RewardItem ->
|
1023
959
|
isAdSkip = 2
|
1024
960
|
val rewardAmount = rewardItem.amount
|
1025
961
|
val rewardType = rewardItem.type
|
@@ -1027,7 +963,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1027
963
|
try {
|
1028
964
|
result.put("rewardType", rewardType)
|
1029
965
|
result.put("rewardAmount", rewardAmount)
|
1030
|
-
cWebView
|
966
|
+
cWebView?.loadUrl(
|
1031
967
|
"javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward', ${result});"
|
1032
968
|
)
|
1033
969
|
} catch (e: JSONException) {
|
@@ -1044,7 +980,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1044
980
|
return true
|
1045
981
|
} else if (action == "showPrivacyOptionsForm") {
|
1046
982
|
if (mActivity != null) {
|
1047
|
-
mActivity
|
983
|
+
mActivity?.runOnUiThread {
|
1048
984
|
try {
|
1049
985
|
val params: ConsentRequestParameters
|
1050
986
|
if (this.setDebugGeography) {
|
@@ -1077,8 +1013,8 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1077
1013
|
it1
|
1078
1014
|
) { loadAndShowError: FormError? ->
|
1079
1015
|
if (loadAndShowError != null) {
|
1080
|
-
mActivity
|
1081
|
-
cWebView
|
1016
|
+
mActivity?.runOnUiThread {
|
1017
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + loadAndShowError.message + "' });")
|
1082
1018
|
}
|
1083
1019
|
}
|
1084
1020
|
if (isPrivacyOptionsRequired == ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED) {
|
@@ -1087,8 +1023,8 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1087
1023
|
it2
|
1088
1024
|
) { formError: FormError? ->
|
1089
1025
|
if (formError != null) {
|
1090
|
-
mActivity
|
1091
|
-
cWebView
|
1026
|
+
mActivity?.runOnUiThread {
|
1027
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show.options', { message: '" + formError.message + "' });")
|
1092
1028
|
}
|
1093
1029
|
}
|
1094
1030
|
}
|
@@ -1098,7 +1034,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1098
1034
|
}
|
1099
1035
|
},
|
1100
1036
|
{ requestConsentError: FormError ->
|
1101
|
-
cWebView
|
1037
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed', { message: '" + requestConsentError.message + "' });")
|
1102
1038
|
})
|
1103
1039
|
}
|
1104
1040
|
} catch (e: Exception) {
|
@@ -1109,9 +1045,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1109
1045
|
return true
|
1110
1046
|
} else if (action == "consentReset") {
|
1111
1047
|
if (mActivity != null) {
|
1112
|
-
mActivity
|
1048
|
+
mActivity?.runOnUiThread {
|
1113
1049
|
try {
|
1114
|
-
consentInformation
|
1050
|
+
consentInformation?.reset()
|
1115
1051
|
} catch (e: Exception) {
|
1116
1052
|
callbackContext.error(e.toString())
|
1117
1053
|
}
|
@@ -1120,11 +1056,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1120
1056
|
return true
|
1121
1057
|
} else if (action == "getIabTfc") {
|
1122
1058
|
if (mActivity != null) {
|
1123
|
-
mActivity
|
1124
|
-
val gdprApplies = mPreferences
|
1125
|
-
val purposeConsents = mPreferences
|
1126
|
-
val vendorConsents = mPreferences
|
1127
|
-
val consentString = mPreferences
|
1059
|
+
mActivity?.runOnUiThread {
|
1060
|
+
val gdprApplies = mPreferences?.getInt("IABTCF_gdprApplies", 0)
|
1061
|
+
val purposeConsents = mPreferences?.getString("IABTCF_PurposeConsents", "")
|
1062
|
+
val vendorConsents = mPreferences?.getString("IABTCF_VendorConsents", "")
|
1063
|
+
val consentString = mPreferences?.getString("IABTCF_TCString", "")
|
1128
1064
|
val userInfoJson = JSONObject()
|
1129
1065
|
try {
|
1130
1066
|
userInfoJson.put("IABTCF_gdprApplies", gdprApplies)
|
@@ -1138,10 +1074,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1138
1074
|
//val key = "IABTCF_TCString"
|
1139
1075
|
getString(consentString.toString())
|
1140
1076
|
callbackContext.success(userInfoJson)
|
1141
|
-
cWebView
|
1077
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc');")
|
1142
1078
|
} catch (e: Exception) {
|
1143
1079
|
callbackContext.error(e.toString())
|
1144
|
-
cWebView
|
1080
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc.error');")
|
1145
1081
|
}
|
1146
1082
|
}
|
1147
1083
|
}
|
@@ -1149,7 +1085,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1149
1085
|
} else if (action == "loadBannerAd") {
|
1150
1086
|
if (mActivity != null) {
|
1151
1087
|
val options = args.getJSONObject(0)
|
1152
|
-
mActivity
|
1088
|
+
mActivity?.runOnUiThread {
|
1153
1089
|
val adUnitId = options.optString("adUnitId")
|
1154
1090
|
val position = options.optString("position")
|
1155
1091
|
val collapsible = options.optString("collapsible")
|
@@ -1174,19 +1110,19 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1174
1110
|
return true
|
1175
1111
|
} else if (action == "showBannerAd") {
|
1176
1112
|
if (mActivity != null) {
|
1177
|
-
mActivity
|
1113
|
+
mActivity?.runOnUiThread {
|
1178
1114
|
if (isBannerPause == 0) {
|
1179
1115
|
isShowBannerAds
|
1180
1116
|
} else if (isBannerPause == 1) {
|
1181
1117
|
try {
|
1182
|
-
bannerView
|
1183
|
-
bannerView
|
1118
|
+
bannerView?.visibility = View.VISIBLE
|
1119
|
+
bannerView?.resume()
|
1184
1120
|
|
1185
1121
|
if (isOverlapping) {
|
1186
1122
|
bannerOverlapping()
|
1187
1123
|
}
|
1188
1124
|
|
1189
|
-
bannerViewLayout
|
1125
|
+
bannerViewLayout?.requestFocus();
|
1190
1126
|
|
1191
1127
|
|
1192
1128
|
} catch (e: Exception) {
|
@@ -1199,7 +1135,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1199
1135
|
} else if (action == "styleBannerAd") {
|
1200
1136
|
val options = args.getJSONObject(0)
|
1201
1137
|
if (mActivity != null) {
|
1202
|
-
mActivity
|
1138
|
+
mActivity?.runOnUiThread {
|
1203
1139
|
val screenHeight: Int
|
1204
1140
|
val usableHeight: Int
|
1205
1141
|
|
@@ -1265,11 +1201,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1265
1201
|
return true
|
1266
1202
|
} else if (action == "hideBannerAd") {
|
1267
1203
|
if (mActivity != null) {
|
1268
|
-
mActivity
|
1204
|
+
mActivity?.runOnUiThread {
|
1269
1205
|
if (isBannerShow) {
|
1270
1206
|
try {
|
1271
|
-
bannerView
|
1272
|
-
bannerView
|
1207
|
+
bannerView?.visibility = View.GONE
|
1208
|
+
bannerView?.pause()
|
1273
1209
|
isBannerLoad = false
|
1274
1210
|
isBannerPause = 1
|
1275
1211
|
bannerOverlappingToZero()
|
@@ -1282,12 +1218,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1282
1218
|
return true
|
1283
1219
|
} else if (action == "removeBannerAd") {
|
1284
1220
|
if (mActivity != null) {
|
1285
|
-
mActivity
|
1221
|
+
mActivity?.runOnUiThread {
|
1286
1222
|
try {
|
1287
1223
|
if (bannerViewLayout != null && bannerView != null) {
|
1288
1224
|
bannerOverlappingToZero()
|
1289
|
-
bannerViewLayout
|
1290
|
-
bannerView
|
1225
|
+
bannerViewLayout?.removeView(bannerView)
|
1226
|
+
bannerView?.destroy()
|
1291
1227
|
bannerView = null
|
1292
1228
|
bannerViewLayout = null
|
1293
1229
|
isBannerLoad = false
|
@@ -1304,7 +1240,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1304
1240
|
|
1305
1241
|
} else if (action == "registerWebView") {
|
1306
1242
|
if (mActivity != null) {
|
1307
|
-
mActivity
|
1243
|
+
mActivity?.runOnUiThread {
|
1308
1244
|
try {
|
1309
1245
|
registerWebView(callbackContext)
|
1310
1246
|
} catch (e: Exception) {
|
@@ -1317,11 +1253,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1317
1253
|
val options = args.getJSONObject(0)
|
1318
1254
|
if (mActivity != null) {
|
1319
1255
|
val url = options.optString("url")
|
1320
|
-
mActivity
|
1256
|
+
mActivity?.runOnUiThread {
|
1321
1257
|
try {
|
1322
1258
|
loadUrl(url, callbackContext)
|
1323
1259
|
} catch (e: Exception) {
|
1324
|
-
PUBLIC_CALLBACKS
|
1260
|
+
PUBLIC_CALLBACKS?.error("Error load Url: " + e.message)
|
1325
1261
|
}
|
1326
1262
|
}
|
1327
1263
|
|
@@ -1367,7 +1303,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1367
1303
|
|
1368
1304
|
|
1369
1305
|
private fun loadBannerAd(adUnitId: String, position: String, size: String) {
|
1370
|
-
adType = size
|
1306
|
+
adType = size
|
1371
1307
|
try {
|
1372
1308
|
if (bannerViewLayout == null) {
|
1373
1309
|
bannerViewLayout = FrameLayout(mActivity!!)
|
@@ -1375,19 +1311,19 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1375
1311
|
FrameLayout.LayoutParams.MATCH_PARENT,
|
1376
1312
|
FrameLayout.LayoutParams.MATCH_PARENT
|
1377
1313
|
)
|
1378
|
-
val decorView = mActivity
|
1314
|
+
val decorView = mActivity?.window?.decorView as ViewGroup
|
1379
1315
|
decorView.addView(bannerViewLayout, params)
|
1380
1316
|
bannerView = AdView(mActivity!!)
|
1381
1317
|
setBannerPosition(position)
|
1382
|
-
|
1383
|
-
bannerView
|
1384
|
-
bannerView
|
1385
|
-
bannerView
|
1318
|
+
setBannerSize(size)
|
1319
|
+
bannerView?.adUnitId = adUnitId
|
1320
|
+
bannerView?.adListener = bannerAdListener
|
1321
|
+
bannerView?.loadAd(buildAdRequest())
|
1386
1322
|
} else {
|
1387
1323
|
Log.d(TAG, "Banner view layout already exists.")
|
1388
1324
|
}
|
1389
1325
|
} catch (e: Exception) {
|
1390
|
-
PUBLIC_CALLBACKS
|
1326
|
+
PUBLIC_CALLBACKS?.error("Error showing banner: " + e.message)
|
1391
1327
|
Log.d(TAG, "Error showing banner: " + e.message)
|
1392
1328
|
}
|
1393
1329
|
}
|
@@ -1459,9 +1395,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1459
1395
|
try {
|
1460
1396
|
if (mActivity != null && bannerView != null && bannerViewLayout != null) {
|
1461
1397
|
if (lock) {
|
1462
|
-
bannerViewLayout
|
1463
|
-
bannerViewLayout
|
1464
|
-
bannerViewLayout
|
1398
|
+
bannerViewLayout?.addView(bannerView)
|
1399
|
+
bannerViewLayout?.bringToFront()
|
1400
|
+
bannerViewLayout?.requestFocus();
|
1465
1401
|
lock = false
|
1466
1402
|
}
|
1467
1403
|
isBannerPause = 0
|
@@ -1469,12 +1405,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1469
1405
|
} else {
|
1470
1406
|
val errorMessage = "Error showing banner: bannerView or bannerViewLayout is null."
|
1471
1407
|
// Log.e("isBannerAutoShow", errorMessage)
|
1472
|
-
PUBLIC_CALLBACKS
|
1408
|
+
PUBLIC_CALLBACKS?.error(errorMessage)
|
1473
1409
|
}
|
1474
1410
|
} catch (e: Exception) {
|
1475
1411
|
val errorMessage = "Error showing banner: " + e.message
|
1476
1412
|
// Log.e("isBannerAutoShow", errorMessage, e)
|
1477
|
-
PUBLIC_CALLBACKS
|
1413
|
+
PUBLIC_CALLBACKS?.error(errorMessage)
|
1478
1414
|
}
|
1479
1415
|
}
|
1480
1416
|
|
@@ -1484,15 +1420,15 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1484
1420
|
if (mActivity != null && isBannerLoad && bannerView != null) {
|
1485
1421
|
try {
|
1486
1422
|
if (lock) {
|
1487
|
-
bannerViewLayout
|
1488
|
-
bannerViewLayout
|
1489
|
-
bannerViewLayout
|
1423
|
+
bannerViewLayout?.addView(bannerView)
|
1424
|
+
bannerViewLayout?.bringToFront()
|
1425
|
+
bannerViewLayout?.requestFocus();
|
1490
1426
|
lock = false
|
1491
1427
|
}
|
1492
1428
|
isBannerShow = true
|
1493
1429
|
} catch (e: Exception) {
|
1494
1430
|
lock = true
|
1495
|
-
PUBLIC_CALLBACKS
|
1431
|
+
PUBLIC_CALLBACKS?.error(e.toString())
|
1496
1432
|
}
|
1497
1433
|
}
|
1498
1434
|
}
|
@@ -1517,12 +1453,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1517
1453
|
|
1518
1454
|
val responseId = adError.responseInfo?.responseId.toString()
|
1519
1455
|
val responseExtras = adError.responseInfo?.responseExtras.toString()
|
1520
|
-
val loadedAdapterResponseInfo =
|
1521
|
-
|
1522
|
-
val
|
1523
|
-
adError.responseInfo?.mediationAdapterClassName.toString()
|
1524
|
-
val adapterResponses =
|
1525
|
-
adError.responseInfo?.adapterResponses.toString()
|
1456
|
+
val loadedAdapterResponseInfo = adError.responseInfo?.loadedAdapterResponseInfo.toString()
|
1457
|
+
val mediationAdapterClassName = adError.responseInfo?.mediationAdapterClassName.toString()
|
1458
|
+
val adapterResponses = adError.responseInfo?.adapterResponses.toString()
|
1526
1459
|
|
1527
1460
|
put("responseInfoId", responseId)
|
1528
1461
|
put("responseInfoExtras", responseExtras)
|
@@ -1536,8 +1469,8 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1536
1469
|
bannerOverlappingToZero()
|
1537
1470
|
|
1538
1471
|
if (bannerViewLayout != null && bannerView != null) {
|
1539
|
-
bannerViewLayout
|
1540
|
-
bannerView
|
1472
|
+
bannerViewLayout?.removeView(bannerView)
|
1473
|
+
bannerView?.destroy()
|
1541
1474
|
bannerView = null
|
1542
1475
|
bannerViewLayout = null
|
1543
1476
|
isBannerLoad = false
|
@@ -1575,10 +1508,6 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1575
1508
|
}
|
1576
1509
|
|
1577
1510
|
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
1511
|
val context = cordova.activity.applicationContext
|
1583
1512
|
//val adType="fluid";
|
1584
1513
|
// Get the AdSize object based on the type
|
@@ -1604,9 +1533,6 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1604
1533
|
val bannerLoadEventData = String.format(Locale.US, "{\"height\": %d}", bannerHeightDp)
|
1605
1534
|
|
1606
1535
|
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
1536
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load', $bannerLoadEventData);")
|
1611
1537
|
|
1612
1538
|
val eventData = String.format(
|
@@ -1614,22 +1540,19 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1614
1540
|
if (bannerView!!.isCollapsible) "collapsible" else "not collapsible"
|
1615
1541
|
)
|
1616
1542
|
|
1617
|
-
cWebView
|
1543
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.is.collapsible', $eventData)")
|
1618
1544
|
|
1619
|
-
bannerView
|
1545
|
+
bannerView?.onPaidEventListener = bannerPaidAdListener
|
1620
1546
|
|
1621
1547
|
if (isResponseInfo) {
|
1622
1548
|
val result = JSONObject()
|
1623
|
-
val responseInfo = bannerView
|
1549
|
+
val responseInfo = bannerView?.responseInfo
|
1624
1550
|
try {
|
1625
1551
|
checkNotNull(responseInfo)
|
1626
1552
|
result.put("getResponseId", responseInfo.responseId)
|
1627
1553
|
result.put("getAdapterResponses", responseInfo.adapterResponses)
|
1628
1554
|
result.put("getResponseExtras", responseInfo.responseExtras)
|
1629
|
-
result.put(
|
1630
|
-
"getMediationAdapterClassName",
|
1631
|
-
responseInfo.mediationAdapterClassName
|
1632
|
-
)
|
1555
|
+
result.put("getMediationAdapterClassName", responseInfo.mediationAdapterClassName)
|
1633
1556
|
if (mBundleExtra != null) {
|
1634
1557
|
result.put("getBundleExtra", mBundleExtra.toString())
|
1635
1558
|
} else {
|
@@ -1653,24 +1576,24 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1653
1576
|
|
1654
1577
|
private fun bannerOverlappingToZero() {
|
1655
1578
|
if (bannerView != null && mActivity != null && cWebView != null) {
|
1656
|
-
mActivity
|
1579
|
+
mActivity?.runOnUiThread {
|
1657
1580
|
try {
|
1658
|
-
val rootView = (cWebView
|
1581
|
+
val rootView = (cWebView?.view?.parent as View)
|
1659
1582
|
rootView.post {
|
1660
1583
|
// Get the total height of the parent view
|
1661
1584
|
val totalHeight = rootView.height
|
1662
1585
|
|
1663
1586
|
// Adjust WebView height to match parent height
|
1664
|
-
val layoutParams = cWebView
|
1665
|
-
layoutParams
|
1666
|
-
cWebView
|
1587
|
+
val layoutParams = cWebView?.view?.layoutParams
|
1588
|
+
layoutParams?.height = totalHeight
|
1589
|
+
cWebView?.view?.layoutParams = layoutParams
|
1667
1590
|
|
1668
1591
|
// Ensure no padding/margin in WebView or its parent
|
1669
|
-
cWebView
|
1670
|
-
(cWebView
|
1592
|
+
cWebView?.view?.setPadding(0, 0, 0, 0)
|
1593
|
+
(cWebView?.view?.parent as? ViewGroup)?.setPadding(0, 0, 0, 0)
|
1671
1594
|
|
1672
1595
|
// Force layout update
|
1673
|
-
cWebView
|
1596
|
+
cWebView?.view?.requestLayout()
|
1674
1597
|
|
1675
1598
|
Log.d("BannerAdjustment", "WebView set to full height: $totalHeight")
|
1676
1599
|
}
|
@@ -1686,17 +1609,17 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1686
1609
|
|
1687
1610
|
private fun bannerOverlapping() {
|
1688
1611
|
if (bannerView != null && mActivity != null && cWebView != null) {
|
1689
|
-
mActivity
|
1612
|
+
mActivity?.runOnUiThread {
|
1690
1613
|
try {
|
1691
1614
|
|
1692
1615
|
val displayMetrics = DisplayMetrics()
|
1693
|
-
mActivity
|
1616
|
+
mActivity?.windowManager?.defaultDisplay?.getMetrics(displayMetrics)
|
1694
1617
|
val screenHeightInPx = displayMetrics.heightPixels
|
1695
1618
|
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1619
|
+
val webViewHeight = screenHeightInPx - (adSize.height + overlappingHeight)
|
1620
|
+
val layoutParams = cWebView?.view?.layoutParams
|
1621
|
+
layoutParams?.height = webViewHeight
|
1622
|
+
cWebView?.view?.layoutParams = layoutParams
|
1700
1623
|
|
1701
1624
|
// Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
|
1702
1625
|
} catch (e: Exception) {
|
@@ -1713,10 +1636,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1713
1636
|
|
1714
1637
|
|
1715
1638
|
private val bannerPaidAdListener = OnPaidEventListener { adValue ->
|
1716
|
-
val valueMicros = adValue.valueMicros
|
1717
|
-
val currencyCode = adValue.currencyCode
|
1718
|
-
val precision = adValue.precisionType
|
1719
|
-
val adUnitId = bannerView
|
1639
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
1640
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
1641
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
1642
|
+
val adUnitId = bannerView?.adUnitId ?: "null"
|
1720
1643
|
val result = JSONObject()
|
1721
1644
|
try {
|
1722
1645
|
result.put("micros", valueMicros)
|
@@ -1732,33 +1655,33 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1732
1655
|
}
|
1733
1656
|
|
1734
1657
|
|
1735
|
-
private fun
|
1658
|
+
private fun setBannerSize(size: String?) {
|
1736
1659
|
when (size) {
|
1737
|
-
"responsive_adaptive" -> bannerView
|
1738
|
-
"anchored_adaptive" -> bannerView
|
1660
|
+
"responsive_adaptive" -> bannerView?.setAdSize(adSize)
|
1661
|
+
"anchored_adaptive" -> bannerView?.setAdSize(
|
1739
1662
|
AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
|
1740
1663
|
mActivity!!, adWidth
|
1741
1664
|
)
|
1742
1665
|
)
|
1743
1666
|
|
1744
|
-
"full_width_adaptive" -> bannerView
|
1667
|
+
"full_width_adaptive" -> bannerView?.setAdSize(
|
1745
1668
|
AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
|
1746
1669
|
mActivity!!, adWidth
|
1747
1670
|
)
|
1748
1671
|
)
|
1749
1672
|
|
1750
|
-
"in_line_adaptive" -> bannerView
|
1673
|
+
"in_line_adaptive" -> bannerView?.setAdSize(
|
1751
1674
|
AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(
|
1752
1675
|
mActivity!!, adWidth
|
1753
1676
|
)
|
1754
1677
|
)
|
1755
1678
|
|
1756
|
-
"banner" -> bannerView
|
1757
|
-
"large_banner" -> bannerView
|
1758
|
-
"medium_rectangle" -> bannerView
|
1759
|
-
"full_banner" -> bannerView
|
1760
|
-
"leaderboard" -> bannerView
|
1761
|
-
"fluid" -> bannerView
|
1679
|
+
"banner" -> bannerView?.setAdSize(AdSize.BANNER)
|
1680
|
+
"large_banner" -> bannerView?.setAdSize(AdSize.LARGE_BANNER)
|
1681
|
+
"medium_rectangle" -> bannerView?.setAdSize(AdSize.MEDIUM_RECTANGLE)
|
1682
|
+
"full_banner" -> bannerView?.setAdSize(AdSize.FULL_BANNER)
|
1683
|
+
"leaderboard" -> bannerView?.setAdSize(AdSize.LEADERBOARD)
|
1684
|
+
"fluid" -> bannerView?.setAdSize(AdSize.FLUID)
|
1762
1685
|
}
|
1763
1686
|
}
|
1764
1687
|
|
@@ -1777,7 +1700,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1777
1700
|
outMetrics.density = mActivity!!.resources.displayMetrics.density
|
1778
1701
|
} else {
|
1779
1702
|
@Suppress("DEPRECATION")
|
1780
|
-
mActivity
|
1703
|
+
mActivity?.windowManager?.defaultDisplay?.getMetrics(outMetrics)
|
1781
1704
|
}
|
1782
1705
|
|
1783
1706
|
val density = outMetrics.density
|
@@ -1824,15 +1747,15 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1824
1747
|
it1
|
1825
1748
|
) { formError: FormError? ->
|
1826
1749
|
if (formError != null) {
|
1827
|
-
mActivity
|
1828
|
-
cWebView
|
1750
|
+
mActivity?.runOnUiThread {
|
1751
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show', { message: '" + formError.message + "' });")
|
1829
1752
|
}
|
1830
1753
|
}
|
1831
1754
|
}
|
1832
1755
|
}
|
1833
1756
|
},
|
1834
1757
|
{ formError: FormError ->
|
1835
|
-
cWebView
|
1758
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from', { message: '" + formError.message + "' });")
|
1836
1759
|
}
|
1837
1760
|
)
|
1838
1761
|
}
|
@@ -1897,64 +1820,70 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1897
1820
|
}
|
1898
1821
|
|
1899
1822
|
|
1823
|
+
|
1824
|
+
|
1825
|
+
|
1900
1826
|
@SuppressLint("DefaultLocale")
|
1901
1827
|
private fun initializeMobileAdsSdk() {
|
1828
|
+
|
1902
1829
|
if (isMobileAdsInitializeCalled.getAndSet(true)) {
|
1903
1830
|
return
|
1904
1831
|
}
|
1905
1832
|
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
val mStatus = consentInformation?.consentStatus.toString()
|
1923
|
-
|
1924
|
-
val adapterInfo = StringBuilder()
|
1925
|
-
for (adapterClass in statusMap.keys) {
|
1926
|
-
val status = statusMap[adapterClass]
|
1927
|
-
if (status != null) {
|
1928
|
-
adapterInfo.append(
|
1929
|
-
String.format(
|
1930
|
-
"Adapter name:%s, Description:%s, Latency:%d\n",
|
1931
|
-
adapterClass, status.description, status.latency
|
1833
|
+
if (mActivity != null && cWebView != null) {
|
1834
|
+
CoroutineScope(Dispatchers.IO).launch {
|
1835
|
+
try {
|
1836
|
+
MobileAds.initialize(mActivity!!) { initializationStatus ->
|
1837
|
+
|
1838
|
+
val statusMap = initializationStatus.adapterStatusMap
|
1839
|
+
val adapterInfo = StringBuilder()
|
1840
|
+
|
1841
|
+
for ((adapterClass, status) in statusMap) {
|
1842
|
+
adapterInfo.append(
|
1843
|
+
String.format(
|
1844
|
+
"Adapter name: %s, Description: %s, Latency: %d\n",
|
1845
|
+
adapterClass,
|
1846
|
+
status.description,
|
1847
|
+
status.latency
|
1848
|
+
)
|
1932
1849
|
)
|
1933
|
-
|
1850
|
+
}
|
1851
|
+
|
1852
|
+
val gdprApplies = mPreferences?.getInt("IABTCF_gdprApplies", 0)
|
1853
|
+
val purposeConsents = mPreferences?.getString("IABTCF_PurposeConsents", "")
|
1854
|
+
val vendorConsents = mPreferences?.getString("IABTCF_VendorConsents", "")
|
1855
|
+
val consentTCString = mPreferences?.getString("IABTCF_TCString", "")
|
1856
|
+
val additionalConsent = mPreferences?.getString("IABTCF_AddtlConsent", "")
|
1857
|
+
|
1858
|
+
val sdkVersion = MobileAds.getVersion().toString()
|
1859
|
+
val consentStatus = consentInformation?.consentStatus.toString()
|
1860
|
+
|
1861
|
+
val eventData = """
|
1862
|
+
{
|
1863
|
+
"version": "$sdkVersion",
|
1864
|
+
"adapters": "$adapterInfo",
|
1865
|
+
"consentStatus": "$consentStatus",
|
1866
|
+
"gdprApplies": $gdprApplies,
|
1867
|
+
"purposeConsents": "$purposeConsents",
|
1868
|
+
"vendorConsents": "$vendorConsents",
|
1869
|
+
"consentTCString": "$consentTCString",
|
1870
|
+
"additionalConsent": "$additionalConsent"
|
1871
|
+
}
|
1872
|
+
""".trimIndent()
|
1873
|
+
|
1874
|
+
mActivity?.runOnUiThread {
|
1875
|
+
// Log.d(TAG, "Google Mobile Ads SDK Initialization: $eventData")
|
1876
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization', $eventData)")
|
1877
|
+
}
|
1934
1878
|
}
|
1879
|
+
} catch (e: Exception) {
|
1880
|
+
Log.e(TAG, "Error during MobileAds initialization", e)
|
1935
1881
|
}
|
1882
|
+
}
|
1883
|
+
}
|
1884
|
+
}
|
1936
1885
|
|
1937
|
-
val gdprApplies = mPreferences!!.getInt("IABTCF_gdprApplies", 0)
|
1938
|
-
val purposeConsents = mPreferences!!.getString("IABTCF_PurposeConsents", "")
|
1939
|
-
val vendorConsents = mPreferences!!.getString("IABTCF_VendorConsents", "")
|
1940
|
-
val consentTCString = mPreferences!!.getString("IABTCF_TCString", "")
|
1941
|
-
val additionalConsent = mPreferences!!.getString("IABTCF_AddtlConsent", "")
|
1942
1886
|
|
1943
|
-
val eventData = String.format(
|
1944
|
-
"{ version: '%s', adapters: '%s', consentStatus: '%s', gdprApplies: '%d', purposeConsents: '%s', vendorConsents: '%s', consentTCString: '%s', additionalConsent: '%s' }",
|
1945
|
-
sdkVersion,
|
1946
|
-
adapterInfo,
|
1947
|
-
mStatus,
|
1948
|
-
gdprApplies,
|
1949
|
-
purposeConsents,
|
1950
|
-
vendorConsents,
|
1951
|
-
consentTCString,
|
1952
|
-
additionalConsent
|
1953
|
-
)
|
1954
|
-
Log.d(TAG, "Google Mobile Ads SDK: this.SetTagForUnderAgeOfConsent $eventData")
|
1955
|
-
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization', $eventData)")
|
1956
|
-
}
|
1957
|
-
}
|
1958
1887
|
|
1959
1888
|
|
1960
1889
|
@SuppressLint("DefaultLocale")
|
@@ -2116,7 +2045,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2116
2045
|
|
2117
2046
|
|
2118
2047
|
private fun appOpenAdLoadCallback() {
|
2119
|
-
appOpenAd
|
2048
|
+
appOpenAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2120
2049
|
override fun onAdDismissedFullScreenContent() {
|
2121
2050
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.dismissed');")
|
2122
2051
|
val mainView: View? = view
|
@@ -2132,20 +2061,20 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2132
2061
|
put("domain", adError.domain)
|
2133
2062
|
put("cause", adError.cause?.toString() ?: "null")
|
2134
2063
|
}
|
2135
|
-
cWebView
|
2064
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.show', ${errorData});")
|
2136
2065
|
}
|
2137
2066
|
|
2138
2067
|
override fun onAdShowedFullScreenContent() {
|
2139
|
-
cWebView
|
2068
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.show');")
|
2140
2069
|
}
|
2141
2070
|
}
|
2142
2071
|
}
|
2143
2072
|
|
2144
2073
|
|
2145
2074
|
private fun interstitialAdLoadCallback() {
|
2146
|
-
mInterstitialAd
|
2075
|
+
mInterstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2147
2076
|
override fun onAdClicked() {
|
2148
|
-
cWebView
|
2077
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.click');")
|
2149
2078
|
}
|
2150
2079
|
|
2151
2080
|
override fun onAdDismissedFullScreenContent() {
|
@@ -2153,7 +2082,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2153
2082
|
isInterstitialLoad = false
|
2154
2083
|
val mainView: View? = view
|
2155
2084
|
mainView?.requestFocus()
|
2156
|
-
cWebView
|
2085
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.dismissed');")
|
2157
2086
|
}
|
2158
2087
|
|
2159
2088
|
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
|
@@ -2165,21 +2094,21 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2165
2094
|
put("domain", adError.domain)
|
2166
2095
|
put("cause", adError.cause?.toString() ?: "null")
|
2167
2096
|
}
|
2168
|
-
cWebView
|
2097
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.show', ${errorData});")
|
2169
2098
|
}
|
2170
2099
|
|
2171
2100
|
override fun onAdImpression() {
|
2172
|
-
cWebView
|
2101
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.impression');")
|
2173
2102
|
}
|
2174
2103
|
|
2175
2104
|
override fun onAdShowedFullScreenContent() {
|
2176
|
-
cWebView
|
2105
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.show');")
|
2177
2106
|
}
|
2178
2107
|
}
|
2179
2108
|
}
|
2180
2109
|
|
2181
2110
|
private fun rewardedAdLoadCallback() {
|
2182
|
-
rewardedAd
|
2111
|
+
rewardedAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2183
2112
|
override fun onAdClicked() {
|
2184
2113
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.click');")
|
2185
2114
|
}
|
@@ -2190,7 +2119,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2190
2119
|
isRewardedLoad = false
|
2191
2120
|
val mainView: View? = view
|
2192
2121
|
mainView?.requestFocus()
|
2193
|
-
cWebView
|
2122
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.ad.skip');")
|
2194
2123
|
}
|
2195
2124
|
rewardedAd = null
|
2196
2125
|
isRewardedLoad = false
|
@@ -2221,7 +2150,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2221
2150
|
}
|
2222
2151
|
|
2223
2152
|
private fun rewardedInterstitialAdLoadCallback() {
|
2224
|
-
rewardedInterstitialAd
|
2153
|
+
rewardedInterstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2225
2154
|
override fun onAdClicked() {
|
2226
2155
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.click');")
|
2227
2156
|
}
|
@@ -2288,8 +2217,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2288
2217
|
}
|
2289
2218
|
|
2290
2219
|
private val isPrivacyOptionsRequired: ConsentInformation.PrivacyOptionsRequirementStatus
|
2291
|
-
get() = consentInformation
|
2292
|
-
?.getPrivacyOptionsRequirementStatus() ?: ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
|
2220
|
+
get() = consentInformation?.getPrivacyOptionsRequirementStatus() ?: ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
|
2293
2221
|
|
2294
2222
|
|
2295
2223
|
|
@@ -2356,4 +2284,4 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2356
2284
|
private const val LAST_ACCESS_SUFFIX = "_last_access"
|
2357
2285
|
private const val EXPIRATION_TIME = 360L * 24 * 60 * 60 * 1000
|
2358
2286
|
}
|
2359
|
-
}
|
2287
|
+
}
|