emi-indo-cordova-plugin-admob 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/emiAdmobPlugin.kt +144 -224
package/README.md
CHANGED
package/package.json
CHANGED
package/plugin.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
2
2
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
-
id="emi-indo-cordova-plugin-admob" version="2.0.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="2.0.1">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova/Quasar/Capacitor Plugin Admob Android IOS</description>
|
@@ -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
|
@@ -181,7 +183,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
181
183
|
decorView.addView(bannerViewLayout, params)
|
182
184
|
bannerView = AdView(mActivity!!)
|
183
185
|
setBannerPosition(this.isPosition)
|
184
|
-
|
186
|
+
setBannerSize(this.isSize)
|
185
187
|
bannerView!!.adUnitId = bannerAdUnitId!!
|
186
188
|
bannerView!!.adListener = bannerAdListener
|
187
189
|
bannerView!!.loadAd(buildAdRequest())
|
@@ -432,12 +434,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
432
434
|
|
433
435
|
appOpenAdLoadCallback()
|
434
436
|
|
435
|
-
appOpenAd
|
437
|
+
appOpenAd?.onPaidEventListener =
|
436
438
|
OnPaidEventListener { adValue: AdValue ->
|
437
|
-
val valueMicros = adValue.valueMicros
|
438
|
-
val currencyCode = adValue.currencyCode
|
439
|
-
val precision = adValue.precisionType
|
440
|
-
val appOpenAdAdUnitId = appOpenAd
|
439
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
440
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
441
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
442
|
+
val appOpenAdAdUnitId = appOpenAd?.adUnitId ?: "null"
|
441
443
|
|
442
444
|
val result = JSONObject()
|
443
445
|
try {
|
@@ -456,24 +458,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
456
458
|
|
457
459
|
if (isResponseInfo) {
|
458
460
|
val result = JSONObject()
|
459
|
-
val responseInfo =
|
461
|
+
val responseInfo = appOpenAd?.responseInfo
|
460
462
|
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
|
-
)
|
463
|
+
result.put("getResponseId", responseInfo?.responseId.toString())
|
464
|
+
result.put("getAdapterResponses", responseInfo?.adapterResponses.toString())
|
465
|
+
result.put("getResponseExtras", responseInfo?.responseExtras.toString())
|
466
|
+
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName.toString())
|
477
467
|
result.put("getBundleExtra", mBundleExtra.toString())
|
478
468
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.responseInfo', ${result})")
|
479
469
|
} catch (e: JSONException) {
|
@@ -508,24 +498,16 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
508
498
|
put("domain", loadAdError.domain)
|
509
499
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
510
500
|
|
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()
|
501
|
+
val responseId = loadAdError.responseInfo?.responseId.toString()
|
502
|
+
val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
|
503
|
+
val loadedAdapterResponseInfo = loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
504
|
+
val mediationAdapterClassName = loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
505
|
+
val adapterResponses = loadAdError.responseInfo?.adapterResponses.toString()
|
521
506
|
|
522
507
|
put("responseInfoId", responseId)
|
523
508
|
put("responseInfoExtras", responseExtras)
|
524
509
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
525
|
-
put(
|
526
|
-
"responseInfoMediationAdapterClassName",
|
527
|
-
mediationAdapterClassName
|
528
|
-
)
|
510
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
529
511
|
put("responseInfoAdapterResponses", adapterResponses)
|
530
512
|
}
|
531
513
|
cWebView?.loadUrl(
|
@@ -581,21 +563,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
581
563
|
|
582
564
|
if (isResponseInfo) {
|
583
565
|
val result = JSONObject()
|
584
|
-
val responseInfo = mInterstitialAd
|
566
|
+
val responseInfo = mInterstitialAd?.responseInfo
|
585
567
|
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
|
-
)
|
568
|
+
result.put("getResponseId", responseInfo?.responseId)
|
569
|
+
result.put("getAdapterResponses", responseInfo?.adapterResponses)
|
570
|
+
result.put("getResponseExtras", responseInfo?.responseExtras)
|
571
|
+
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName)
|
599
572
|
result.put("getBundleExtra", mBundleExtra.toString())
|
600
573
|
cWebView!!.loadUrl(
|
601
574
|
"javascript:cordova.fireDocumentEvent('on.interstitialAd.responseInfo', ${result});"
|
@@ -605,12 +578,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
605
578
|
callbackContext.error(e.message)
|
606
579
|
}
|
607
580
|
}
|
608
|
-
mInterstitialAd
|
581
|
+
mInterstitialAd?.onPaidEventListener =
|
609
582
|
OnPaidEventListener { adValue: AdValue ->
|
610
|
-
val valueMicros = adValue.valueMicros
|
611
|
-
val currencyCode = adValue.currencyCode
|
612
|
-
val precision = adValue.precisionType
|
613
|
-
val interstitialAdUnitId = mInterstitialAd
|
583
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
584
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
585
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
586
|
+
val interstitialAdUnitId = mInterstitialAd?.adUnitId ?: "null"
|
614
587
|
val result = JSONObject()
|
615
588
|
try {
|
616
589
|
result.put("micros", valueMicros)
|
@@ -649,28 +622,19 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
649
622
|
put("domain", loadAdError.domain)
|
650
623
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
651
624
|
|
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()
|
625
|
+
val responseId = loadAdError.responseInfo?.responseId.toString()
|
626
|
+
val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
|
627
|
+
val loadedAdapterResponseInfo = loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
628
|
+
val mediationAdapterClassName = loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
629
|
+
val adapterResponses = loadAdError.responseInfo?.adapterResponses.toString()
|
662
630
|
|
663
631
|
put("responseInfoId", responseId)
|
664
632
|
put("responseInfoExtras", responseExtras)
|
665
633
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
666
|
-
put(
|
667
|
-
"responseInfoMediationAdapterClassName",
|
668
|
-
mediationAdapterClassName
|
669
|
-
)
|
634
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
670
635
|
put("responseInfoAdapterResponses", adapterResponses)
|
671
636
|
}
|
672
637
|
|
673
|
-
|
674
638
|
cWebView!!.loadUrl(
|
675
639
|
"javascript:cordova.fireDocumentEvent('on.interstitial.failed.load', ${errorData});"
|
676
640
|
)
|
@@ -714,27 +678,18 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
714
678
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
715
679
|
|
716
680
|
|
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()
|
681
|
+
val responseId = loadAdError.responseInfo?.responseId.toString()
|
682
|
+
val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
|
683
|
+
val loadedAdapterResponseInfo = loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
684
|
+
val mediationAdapterClassName = loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
685
|
+
val adapterResponses = loadAdError.responseInfo?.adapterResponses.toString()
|
727
686
|
|
728
687
|
put("responseInfoId", responseId)
|
729
688
|
put("responseInfoExtras", responseExtras)
|
730
689
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
731
|
-
put(
|
732
|
-
"responseInfoMediationAdapterClassName",
|
733
|
-
mediationAdapterClassName
|
734
|
-
)
|
690
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
735
691
|
put("responseInfoAdapterResponses", adapterResponses)
|
736
692
|
|
737
|
-
|
738
693
|
}
|
739
694
|
|
740
695
|
cWebView!!.loadUrl(
|
@@ -758,12 +713,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
758
713
|
"javascript:cordova.fireDocumentEvent('on.rewarded.loaded');"
|
759
714
|
)
|
760
715
|
|
761
|
-
rewardedAd
|
716
|
+
rewardedAd?.onPaidEventListener =
|
762
717
|
OnPaidEventListener { adValue: AdValue ->
|
763
|
-
val valueMicros = adValue.valueMicros
|
764
|
-
val currencyCode = adValue.currencyCode
|
765
|
-
val precision = adValue.precisionType
|
766
|
-
val rewardedAdAdUnitId = rewardedAd
|
718
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
719
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
720
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
721
|
+
val rewardedAdAdUnitId = rewardedAd?.adUnitId ?: "null"
|
767
722
|
val result = JSONObject()
|
768
723
|
try {
|
769
724
|
result.put("micros", valueMicros)
|
@@ -783,21 +738,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
783
738
|
|
784
739
|
if (isResponseInfo) {
|
785
740
|
val result = JSONObject()
|
786
|
-
val responseInfo =
|
741
|
+
val responseInfo = rewardedAd?.responseInfo
|
787
742
|
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
|
-
)
|
743
|
+
result.put("getResponseId", responseInfo?.responseId)
|
744
|
+
result.put("getAdapterResponses", responseInfo?.adapterResponses)
|
745
|
+
result.put("getResponseExtras", responseInfo?.responseExtras)
|
746
|
+
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName)
|
801
747
|
result.put("getBundleExtra", mBundleExtra.toString())
|
802
748
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAd.responseInfo', ${result})")
|
803
749
|
} catch (e: JSONException) {
|
@@ -893,13 +839,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
893
839
|
|
894
840
|
rewardedInterstitialAdLoadCallback()
|
895
841
|
|
896
|
-
rewardedInterstitialAd
|
842
|
+
rewardedInterstitialAd?.onPaidEventListener =
|
897
843
|
OnPaidEventListener { adValue: AdValue ->
|
898
|
-
val valueMicros = adValue.valueMicros
|
899
|
-
val currencyCode = adValue.currencyCode
|
900
|
-
val precision = adValue.precisionType
|
901
|
-
val rewardedIntAdUnitId =
|
902
|
-
rewardedInterstitialAd!!.adUnitId
|
844
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
845
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
846
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
847
|
+
val rewardedIntAdUnitId = rewardedInterstitialAd?.adUnitId ?: "null"
|
903
848
|
val result = JSONObject()
|
904
849
|
try {
|
905
850
|
result.put("micros", valueMicros)
|
@@ -918,21 +863,12 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
918
863
|
|
919
864
|
if (isResponseInfo) {
|
920
865
|
val result = JSONObject()
|
921
|
-
val responseInfo = rewardedInterstitialAd
|
866
|
+
val responseInfo = rewardedInterstitialAd?.responseInfo
|
922
867
|
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
|
-
)
|
868
|
+
result.put("getResponseId", responseInfo?.responseId)
|
869
|
+
result.put("getAdapterResponses", responseInfo?.adapterResponses)
|
870
|
+
result.put("getResponseExtras", responseInfo?.responseExtras)
|
871
|
+
result.put("getMediationAdapterClassName", responseInfo?.mediationAdapterClassName)
|
936
872
|
result.put("getBundleExtra", mBundleExtra.toString())
|
937
873
|
cWebView!!.loadUrl(
|
938
874
|
"javascript:cordova.fireDocumentEvent('on.rewardedIntAd.responseInfo', ${result});"
|
@@ -982,24 +918,16 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
982
918
|
put("domain", loadAdError.domain)
|
983
919
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
984
920
|
|
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()
|
921
|
+
val responseId = loadAdError.responseInfo?.responseId.toString()
|
922
|
+
val responseExtras = loadAdError.responseInfo?.responseExtras.toString()
|
923
|
+
val loadedAdapterResponseInfo = loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
924
|
+
val mediationAdapterClassName = loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
925
|
+
val adapterResponses = loadAdError.responseInfo?.adapterResponses.toString()
|
995
926
|
|
996
927
|
put("responseInfoId", responseId)
|
997
928
|
put("responseInfoExtras", responseExtras)
|
998
929
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
999
|
-
put(
|
1000
|
-
"responseInfoMediationAdapterClassName",
|
1001
|
-
mediationAdapterClassName
|
1002
|
-
)
|
930
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
1003
931
|
put("responseInfoAdapterResponses", adapterResponses)
|
1004
932
|
}
|
1005
933
|
cWebView!!.loadUrl(
|
@@ -1367,7 +1295,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1367
1295
|
|
1368
1296
|
|
1369
1297
|
private fun loadBannerAd(adUnitId: String, position: String, size: String) {
|
1370
|
-
adType = size
|
1298
|
+
adType = size
|
1371
1299
|
try {
|
1372
1300
|
if (bannerViewLayout == null) {
|
1373
1301
|
bannerViewLayout = FrameLayout(mActivity!!)
|
@@ -1379,7 +1307,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1379
1307
|
decorView.addView(bannerViewLayout, params)
|
1380
1308
|
bannerView = AdView(mActivity!!)
|
1381
1309
|
setBannerPosition(position)
|
1382
|
-
|
1310
|
+
setBannerSize(size)
|
1383
1311
|
bannerView!!.adUnitId = adUnitId
|
1384
1312
|
bannerView!!.adListener = bannerAdListener
|
1385
1313
|
bannerView!!.loadAd(buildAdRequest())
|
@@ -1517,12 +1445,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1517
1445
|
|
1518
1446
|
val responseId = adError.responseInfo?.responseId.toString()
|
1519
1447
|
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()
|
1448
|
+
val loadedAdapterResponseInfo = adError.responseInfo?.loadedAdapterResponseInfo.toString()
|
1449
|
+
val mediationAdapterClassName = adError.responseInfo?.mediationAdapterClassName.toString()
|
1450
|
+
val adapterResponses = adError.responseInfo?.adapterResponses.toString()
|
1526
1451
|
|
1527
1452
|
put("responseInfoId", responseId)
|
1528
1453
|
put("responseInfoExtras", responseExtras)
|
@@ -1575,10 +1500,6 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1575
1500
|
}
|
1576
1501
|
|
1577
1502
|
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
1503
|
val context = cordova.activity.applicationContext
|
1583
1504
|
//val adType="fluid";
|
1584
1505
|
// Get the AdSize object based on the type
|
@@ -1604,9 +1525,6 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1604
1525
|
val bannerLoadEventData = String.format(Locale.US, "{\"height\": %d}", bannerHeightDp)
|
1605
1526
|
|
1606
1527
|
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
1528
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load', $bannerLoadEventData);")
|
1611
1529
|
|
1612
1530
|
val eventData = String.format(
|
@@ -1616,20 +1534,17 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1616
1534
|
|
1617
1535
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.is.collapsible', $eventData)")
|
1618
1536
|
|
1619
|
-
bannerView
|
1537
|
+
bannerView?.onPaidEventListener = bannerPaidAdListener
|
1620
1538
|
|
1621
1539
|
if (isResponseInfo) {
|
1622
1540
|
val result = JSONObject()
|
1623
|
-
val responseInfo = bannerView
|
1541
|
+
val responseInfo = bannerView?.responseInfo
|
1624
1542
|
try {
|
1625
1543
|
checkNotNull(responseInfo)
|
1626
1544
|
result.put("getResponseId", responseInfo.responseId)
|
1627
1545
|
result.put("getAdapterResponses", responseInfo.adapterResponses)
|
1628
1546
|
result.put("getResponseExtras", responseInfo.responseExtras)
|
1629
|
-
result.put(
|
1630
|
-
"getMediationAdapterClassName",
|
1631
|
-
responseInfo.mediationAdapterClassName
|
1632
|
-
)
|
1547
|
+
result.put("getMediationAdapterClassName", responseInfo.mediationAdapterClassName)
|
1633
1548
|
if (mBundleExtra != null) {
|
1634
1549
|
result.put("getBundleExtra", mBundleExtra.toString())
|
1635
1550
|
} else {
|
@@ -1693,10 +1608,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1693
1608
|
mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
|
1694
1609
|
val screenHeightInPx = displayMetrics.heightPixels
|
1695
1610
|
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1611
|
+
val webViewHeight = screenHeightInPx - (adSize.height + overlappingHeight)
|
1612
|
+
val layoutParams = cWebView!!.view.layoutParams
|
1613
|
+
layoutParams.height = webViewHeight
|
1614
|
+
cWebView!!.view.layoutParams = layoutParams
|
1700
1615
|
|
1701
1616
|
// Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
|
1702
1617
|
} catch (e: Exception) {
|
@@ -1713,10 +1628,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1713
1628
|
|
1714
1629
|
|
1715
1630
|
private val bannerPaidAdListener = OnPaidEventListener { adValue ->
|
1716
|
-
val valueMicros = adValue.valueMicros
|
1717
|
-
val currencyCode = adValue.currencyCode
|
1718
|
-
val precision = adValue.precisionType
|
1719
|
-
val adUnitId = bannerView
|
1631
|
+
val valueMicros = adValue.valueMicros.takeIf { it > 0 } ?: 0L
|
1632
|
+
val currencyCode = adValue.currencyCode.ifBlank { "UNKNOWN" }
|
1633
|
+
val precision = adValue.precisionType.takeIf { it >= 0 } ?: AdValue.PrecisionType.UNKNOWN
|
1634
|
+
val adUnitId = bannerView?.adUnitId ?: "null"
|
1720
1635
|
val result = JSONObject()
|
1721
1636
|
try {
|
1722
1637
|
result.put("micros", valueMicros)
|
@@ -1732,7 +1647,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1732
1647
|
}
|
1733
1648
|
|
1734
1649
|
|
1735
|
-
private fun
|
1650
|
+
private fun setBannerSize(size: String?) {
|
1736
1651
|
when (size) {
|
1737
1652
|
"responsive_adaptive" -> bannerView!!.setAdSize(adSize)
|
1738
1653
|
"anchored_adaptive" -> bannerView!!.setAdSize(
|
@@ -1897,64 +1812,70 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1897
1812
|
}
|
1898
1813
|
|
1899
1814
|
|
1815
|
+
|
1816
|
+
|
1817
|
+
|
1900
1818
|
@SuppressLint("DefaultLocale")
|
1901
1819
|
private fun initializeMobileAdsSdk() {
|
1820
|
+
|
1902
1821
|
if (isMobileAdsInitializeCalled.getAndSet(true)) {
|
1903
1822
|
return
|
1904
1823
|
}
|
1905
1824
|
|
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
|
1825
|
+
if (mActivity != null && cWebView != null) {
|
1826
|
+
CoroutineScope(Dispatchers.IO).launch {
|
1827
|
+
try {
|
1828
|
+
MobileAds.initialize(mActivity!!) { initializationStatus ->
|
1829
|
+
|
1830
|
+
val statusMap = initializationStatus.adapterStatusMap
|
1831
|
+
val adapterInfo = StringBuilder()
|
1832
|
+
|
1833
|
+
for ((adapterClass, status) in statusMap) {
|
1834
|
+
adapterInfo.append(
|
1835
|
+
String.format(
|
1836
|
+
"Adapter name: %s, Description: %s, Latency: %d\n",
|
1837
|
+
adapterClass,
|
1838
|
+
status.description,
|
1839
|
+
status.latency
|
1840
|
+
)
|
1932
1841
|
)
|
1933
|
-
|
1842
|
+
}
|
1843
|
+
|
1844
|
+
val gdprApplies = mPreferences?.getInt("IABTCF_gdprApplies", 0)
|
1845
|
+
val purposeConsents = mPreferences?.getString("IABTCF_PurposeConsents", "")
|
1846
|
+
val vendorConsents = mPreferences?.getString("IABTCF_VendorConsents", "")
|
1847
|
+
val consentTCString = mPreferences?.getString("IABTCF_TCString", "")
|
1848
|
+
val additionalConsent = mPreferences?.getString("IABTCF_AddtlConsent", "")
|
1849
|
+
|
1850
|
+
val sdkVersion = MobileAds.getVersion().toString()
|
1851
|
+
val consentStatus = consentInformation?.consentStatus.toString()
|
1852
|
+
|
1853
|
+
val eventData = """
|
1854
|
+
{
|
1855
|
+
"version": "$sdkVersion",
|
1856
|
+
"adapters": "$adapterInfo",
|
1857
|
+
"consentStatus": "$consentStatus",
|
1858
|
+
"gdprApplies": $gdprApplies,
|
1859
|
+
"purposeConsents": "$purposeConsents",
|
1860
|
+
"vendorConsents": "$vendorConsents",
|
1861
|
+
"consentTCString": "$consentTCString",
|
1862
|
+
"additionalConsent": "$additionalConsent"
|
1863
|
+
}
|
1864
|
+
""".trimIndent()
|
1865
|
+
|
1866
|
+
mActivity?.runOnUiThread {
|
1867
|
+
// Log.d(TAG, "Google Mobile Ads SDK Initialization: $eventData")
|
1868
|
+
cWebView?.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization', $eventData)")
|
1869
|
+
}
|
1934
1870
|
}
|
1871
|
+
} catch (e: Exception) {
|
1872
|
+
Log.e(TAG, "Error during MobileAds initialization", e)
|
1935
1873
|
}
|
1874
|
+
}
|
1875
|
+
}
|
1876
|
+
}
|
1936
1877
|
|
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
1878
|
|
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
1879
|
|
1959
1880
|
|
1960
1881
|
@SuppressLint("DefaultLocale")
|
@@ -2116,7 +2037,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2116
2037
|
|
2117
2038
|
|
2118
2039
|
private fun appOpenAdLoadCallback() {
|
2119
|
-
appOpenAd
|
2040
|
+
appOpenAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2120
2041
|
override fun onAdDismissedFullScreenContent() {
|
2121
2042
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.dismissed');")
|
2122
2043
|
val mainView: View? = view
|
@@ -2143,7 +2064,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2143
2064
|
|
2144
2065
|
|
2145
2066
|
private fun interstitialAdLoadCallback() {
|
2146
|
-
mInterstitialAd
|
2067
|
+
mInterstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2147
2068
|
override fun onAdClicked() {
|
2148
2069
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.click');")
|
2149
2070
|
}
|
@@ -2179,7 +2100,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2179
2100
|
}
|
2180
2101
|
|
2181
2102
|
private fun rewardedAdLoadCallback() {
|
2182
|
-
rewardedAd
|
2103
|
+
rewardedAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2183
2104
|
override fun onAdClicked() {
|
2184
2105
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.click');")
|
2185
2106
|
}
|
@@ -2221,7 +2142,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2221
2142
|
}
|
2222
2143
|
|
2223
2144
|
private fun rewardedInterstitialAdLoadCallback() {
|
2224
|
-
rewardedInterstitialAd
|
2145
|
+
rewardedInterstitialAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
|
2225
2146
|
override fun onAdClicked() {
|
2226
2147
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.click');")
|
2227
2148
|
}
|
@@ -2288,8 +2209,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2288
2209
|
}
|
2289
2210
|
|
2290
2211
|
private val isPrivacyOptionsRequired: ConsentInformation.PrivacyOptionsRequirementStatus
|
2291
|
-
get() = consentInformation
|
2292
|
-
?.getPrivacyOptionsRequirementStatus() ?: ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
|
2212
|
+
get() = consentInformation?.getPrivacyOptionsRequirementStatus() ?: ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
|
2293
2213
|
|
2294
2214
|
|
2295
2215
|
|
@@ -2356,4 +2276,4 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2356
2276
|
private const val LAST_ACCESS_SUFFIX = "_last_access"
|
2357
2277
|
private const val EXPIRATION_TIME = 360L * 24 * 60 * 60 * 1000
|
2358
2278
|
}
|
2359
|
-
}
|
2279
|
+
}
|