emi-indo-cordova-plugin-admob 1.6.5 → 1.6.6
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 +7 -8
- package/example/www/index.html +4 -0
- package/example/www/js/adSense.js +44 -0
- package/package.json +5 -2
- package/plugin.xml +4 -1
- package/src/android/emiAdmobPlugin.kt +145 -40
- package/www/emiAdmobPlugin.js +6 -0
package/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
|
2
|
-
## New feature suggestion
|
3
|
-
> [!TIP]
|
4
|
-
> - Funding is needed to add a new feature of native ads that can be scrolled within html content elements.
|
5
|
-
> - I will not settle how much funding is needed to add this feature.
|
6
2
|
|
7
|
-
|
8
|
-
# emi-indo-cordova-plugin-admob
|
3
|
+
### emi-indo-cordova-plugin-admob
|
9
4
|
Cordova Plugin Admob Android and IOS
|
5
|
+
## Support
|
6
|
+
- AdMob
|
7
|
+
- AdManager
|
8
|
+
- AdSense New [example ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/adSense.js)
|
9
|
+
|
10
10
|
|
11
11
|
### Mobile Ads SDK (Android: 23.5.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
|
12
12
|
### User Messaging Platform (UMP Android: 3.1.0) [Release Notes:](https://developers.google.com/admob/android/privacy/release-notes)
|
@@ -132,7 +132,6 @@ https://developers.google.com/admob/ios/quick-start
|
|
132
132
|
- Release notes: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases
|
133
133
|
|
134
134
|
## Installation
|
135
|
-
- Recommendation to version-lock the plugin during production
|
136
135
|
- Only platform Android
|
137
136
|
```sh
|
138
137
|
cordova plugin add emi-indo-cordova-plugin-admob --save --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx
|
@@ -175,7 +174,7 @@ cordova plugin rm emi-indo-cordova-plugin-admob
|
|
175
174
|
|
176
175
|
cordova.plugins.emiAdmobPlugin.initialize({
|
177
176
|
|
178
|
-
isUsingAdManagerRequest: true, // true =
|
177
|
+
isUsingAdManagerRequest: true, // true = AdManager | false = AdMob (Default true)
|
179
178
|
isResponseInfo: true, // Default false (Debug true)
|
180
179
|
isConsentDebug: true, // Default false (Debug true)
|
181
180
|
|
package/example/www/index.html
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
<script src="js/interstitialAd.js" defer></script>
|
8
8
|
<script src="js/rewardedAd.js" defer></script>
|
9
9
|
<script src="js/rewardedInterstitialAd.js" defer></script>
|
10
|
+
<script src="js/adSense.js" defer></script>
|
10
11
|
</head>
|
11
12
|
<body>
|
12
13
|
|
@@ -26,6 +27,9 @@
|
|
26
27
|
<p> <button onclick="loadRewardedInt();">Load Rewarded Int Ad</button></p>
|
27
28
|
<p> <button onclick="showRewardedInt();">Show Rewarded int Ad</button></p>
|
28
29
|
|
30
|
+
<p> <button onclick="registerWebView();">AdSense Register</button></p>
|
31
|
+
<p> <button onclick="loadUrl();">AdSense load Url</button></p>
|
32
|
+
|
29
33
|
<p> <button onclick="cleanText();">Clean response Text</button></p>
|
30
34
|
|
31
35
|
</body>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
function registerWebView() {
|
4
|
+
|
5
|
+
if (typeof cordova !== 'undefined') {
|
6
|
+
|
7
|
+
cordova.plugins.emiAdmobPlugin.registerWebView(
|
8
|
+
function(successMessage) {
|
9
|
+
console.log("WebView registered successfully", successMessage);
|
10
|
+
},
|
11
|
+
function(errorMessage) {
|
12
|
+
console.error("If there is an error", errorMessage);
|
13
|
+
}
|
14
|
+
);
|
15
|
+
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
// test Ad https://webview-api-for-ads-test.glitch.me
|
23
|
+
|
24
|
+
function loadUrl() {
|
25
|
+
|
26
|
+
if (typeof cordova !== 'undefined') {
|
27
|
+
|
28
|
+
cordova.plugins.emiAdmobPlugin.loadUrl({
|
29
|
+
url: "https://webview-api-for-ads-test.glitch.me"
|
30
|
+
},
|
31
|
+
function(successMessage) {
|
32
|
+
console.log("URL loaded successfully", successMessage);
|
33
|
+
},
|
34
|
+
function(errorMessage) {
|
35
|
+
console.error("If there is an error", errorMessage);
|
36
|
+
}
|
37
|
+
);
|
38
|
+
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "emi-indo-cordova-plugin-admob",
|
3
|
-
"version": "1.6.
|
3
|
+
"version": "1.6.6",
|
4
4
|
"description": "Cordova Plugin Admob Android IOS Support Capacitor",
|
5
5
|
"cordova": {
|
6
6
|
"id": "emi-indo-cordova-plugin-admob",
|
@@ -24,7 +24,10 @@
|
|
24
24
|
"capacitor",
|
25
25
|
"capacitor-admob",
|
26
26
|
"capacitor-android",
|
27
|
-
"capacitor-ios"
|
27
|
+
"capacitor-ios",
|
28
|
+
"adsense",
|
29
|
+
"webview",
|
30
|
+
"admanager"
|
28
31
|
],
|
29
32
|
"author": "EMI INDO",
|
30
33
|
"email": "cordova.c3addon@gmail.com",
|
package/plugin.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
2
2
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
-
id="emi-indo-cordova-plugin-admob" version="1.6.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="1.6.6">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova Plugin Admob Android IOS</description>
|
@@ -56,6 +56,9 @@
|
|
56
56
|
android:value="true" />
|
57
57
|
<meta-data android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
|
58
58
|
android:value="true" />
|
59
|
+
<meta-data
|
60
|
+
android:name="com.google.android.gms.ads.INTEGRATION_MANAGER"
|
61
|
+
android:value="webview"/>
|
59
62
|
</config-file>
|
60
63
|
|
61
64
|
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
|
@@ -14,6 +14,7 @@ import android.view.Gravity
|
|
14
14
|
import android.view.View
|
15
15
|
import android.view.ViewGroup
|
16
16
|
import android.view.WindowInsets
|
17
|
+
import android.webkit.WebView
|
17
18
|
import android.widget.FrameLayout
|
18
19
|
import androidx.preference.PreferenceManager
|
19
20
|
import com.google.ads.mediation.admob.AdMobAdapter
|
@@ -58,6 +59,7 @@ import java.security.NoSuchAlgorithmException
|
|
58
59
|
import java.util.Locale
|
59
60
|
import java.util.concurrent.atomic.AtomicBoolean
|
60
61
|
|
62
|
+
|
61
63
|
/**
|
62
64
|
* Created by EMI INDO So on Apr 2, 2023
|
63
65
|
*/
|
@@ -224,7 +226,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
224
226
|
|
225
227
|
if (action == "initialize") {
|
226
228
|
val options = args.getJSONObject(0)
|
227
|
-
if(mActivity != null) {
|
229
|
+
if (mActivity != null) {
|
228
230
|
mActivity!!.runOnUiThread {
|
229
231
|
val setAdRequest = options.optBoolean("isUsingAdManagerRequest")
|
230
232
|
val responseInfo = options.optBoolean("isResponseInfo")
|
@@ -289,7 +291,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
289
291
|
return true
|
290
292
|
} else if (action == "targeting") {
|
291
293
|
val options = args.getJSONObject(0)
|
292
|
-
if(mActivity != null) {
|
294
|
+
if (mActivity != null) {
|
293
295
|
mActivity!!.runOnUiThread {
|
294
296
|
try {
|
295
297
|
val childDirectedTreatment = options.optBoolean("childDirectedTreatment")
|
@@ -308,7 +310,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
308
310
|
return true
|
309
311
|
} else if (action == "targetingAdRequest") {
|
310
312
|
val options = args.getJSONObject(0)
|
311
|
-
if(mActivity != null) {
|
313
|
+
if (mActivity != null) {
|
312
314
|
mActivity!!.runOnUiThread {
|
313
315
|
val customTargetingEnabled = options.optBoolean("customTargetingEnabled")
|
314
316
|
val categoryExclusionsEnabled = options.optBoolean("categoryExclusionsEnabled")
|
@@ -346,7 +348,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
346
348
|
return true
|
347
349
|
} else if (action == "setPersonalizationState") {
|
348
350
|
val options = args.getJSONObject(0)
|
349
|
-
if(mActivity != null) {
|
351
|
+
if (mActivity != null) {
|
350
352
|
mActivity!!.runOnUiThread {
|
351
353
|
val setPPT = options.optString("setPersonalizationState")
|
352
354
|
try {
|
@@ -360,7 +362,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
360
362
|
return true
|
361
363
|
} else if (action == "setPPS") {
|
362
364
|
val options = args.getJSONObject(0)
|
363
|
-
if(mActivity != null) {
|
365
|
+
if (mActivity != null) {
|
364
366
|
mActivity!!.runOnUiThread {
|
365
367
|
val ppsEnabled = options.optBoolean("ppsEnabled")
|
366
368
|
val iabContent = options.optString("iabContent")
|
@@ -378,7 +380,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
378
380
|
return true
|
379
381
|
} else if (action == "globalSettings") {
|
380
382
|
val options = args.getJSONObject(0)
|
381
|
-
if(mActivity != null) {
|
383
|
+
if (mActivity != null) {
|
382
384
|
mActivity!!.runOnUiThread {
|
383
385
|
val setAppMuted = options.optBoolean("setAppMuted")
|
384
386
|
val setAppVolume = options.optInt("setAppVolume").toFloat()
|
@@ -393,7 +395,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
393
395
|
return true
|
394
396
|
} else if (action == "loadAppOpenAd") {
|
395
397
|
val options = args.getJSONObject(0)
|
396
|
-
if(mActivity != null) {
|
398
|
+
if (mActivity != null) {
|
397
399
|
mActivity!!.runOnUiThread {
|
398
400
|
val adUnitId = options.optString("adUnitId")
|
399
401
|
val autoShow = options.optBoolean("autoShow")
|
@@ -443,7 +445,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
443
445
|
val result = JSONObject()
|
444
446
|
val responseInfo = ad.responseInfo
|
445
447
|
try {
|
446
|
-
result.put(
|
448
|
+
result.put(
|
449
|
+
"getResponseId",
|
450
|
+
responseInfo.responseId.toString()
|
451
|
+
)
|
447
452
|
result.put(
|
448
453
|
"getAdapterResponses",
|
449
454
|
responseInfo.adapterResponses.toString()
|
@@ -481,14 +486,34 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
481
486
|
PUBLIC_CALLBACKS!!.error(e.toString())
|
482
487
|
}
|
483
488
|
}
|
489
|
+
|
484
490
|
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
|
485
491
|
isAppOpenAdShow = false
|
486
492
|
val errorData = JSONObject().apply {
|
487
|
-
put("responseInfo", loadAdError.responseInfo.toString())
|
488
493
|
put("code", loadAdError.code)
|
489
494
|
put("message", loadAdError.message)
|
490
495
|
put("domain", loadAdError.domain)
|
491
496
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
497
|
+
|
498
|
+
val responseId =
|
499
|
+
loadAdError.responseInfo?.responseId.toString()
|
500
|
+
val responseExtras =
|
501
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
502
|
+
val loadedAdapterResponseInfo =
|
503
|
+
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
504
|
+
val mediationAdapterClassName =
|
505
|
+
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
506
|
+
val adapterResponses =
|
507
|
+
loadAdError.responseInfo?.adapterResponses.toString()
|
508
|
+
|
509
|
+
put("responseInfoId", responseId)
|
510
|
+
put("responseInfoExtras", responseExtras)
|
511
|
+
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
512
|
+
put(
|
513
|
+
"responseInfoMediationAdapterClassName",
|
514
|
+
mediationAdapterClassName
|
515
|
+
)
|
516
|
+
put("responseInfoAdapterResponses", adapterResponses)
|
492
517
|
}
|
493
518
|
cWebView?.loadUrl(
|
494
519
|
"javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded', ${errorData});"
|
@@ -496,7 +521,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
496
521
|
}
|
497
522
|
|
498
523
|
})
|
499
|
-
|
524
|
+
} catch (e: Exception) {
|
500
525
|
callbackContext.error(e.toString())
|
501
526
|
}
|
502
527
|
}
|
@@ -518,7 +543,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
518
543
|
return true
|
519
544
|
} else if (action == "loadInterstitialAd") {
|
520
545
|
val options = args.getJSONObject(0)
|
521
|
-
if(mActivity != null) {
|
546
|
+
if (mActivity != null) {
|
522
547
|
mActivity!!.runOnUiThread {
|
523
548
|
val adUnitId = options.optString("adUnitId")
|
524
549
|
val autoShow = options.optBoolean("autoShow")
|
@@ -550,7 +575,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
550
575
|
"getAdapterResponses",
|
551
576
|
responseInfo.adapterResponses
|
552
577
|
)
|
553
|
-
result.put(
|
578
|
+
result.put(
|
579
|
+
"getResponseExtras",
|
580
|
+
responseInfo.responseExtras
|
581
|
+
)
|
554
582
|
result.put(
|
555
583
|
"getMediationAdapterClassName",
|
556
584
|
responseInfo.mediationAdapterClassName
|
@@ -590,7 +618,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
590
618
|
private val isIntAutoShow: Unit
|
591
619
|
get() {
|
592
620
|
if (mActivity != null && isInterstitialLoad && mInterstitialAd != null) {
|
593
|
-
mActivity!!.runOnUiThread {
|
621
|
+
mActivity!!.runOnUiThread {
|
622
|
+
mInterstitialAd!!.show(
|
623
|
+
mActivity!!
|
624
|
+
)
|
625
|
+
}
|
594
626
|
}
|
595
627
|
}
|
596
628
|
|
@@ -604,8 +636,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
604
636
|
put("domain", loadAdError.domain)
|
605
637
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
606
638
|
|
607
|
-
val responseId =
|
608
|
-
|
639
|
+
val responseId =
|
640
|
+
loadAdError.responseInfo?.responseId.toString()
|
641
|
+
val responseExtras =
|
642
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
609
643
|
val loadedAdapterResponseInfo =
|
610
644
|
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
611
645
|
val mediationAdapterClassName =
|
@@ -616,7 +650,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
616
650
|
put("responseInfoId", responseId)
|
617
651
|
put("responseInfoExtras", responseExtras)
|
618
652
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
619
|
-
put(
|
653
|
+
put(
|
654
|
+
"responseInfoMediationAdapterClassName",
|
655
|
+
mediationAdapterClassName
|
656
|
+
)
|
620
657
|
put("responseInfoAdapterResponses", adapterResponses)
|
621
658
|
}
|
622
659
|
|
@@ -644,7 +681,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
644
681
|
return true
|
645
682
|
} else if (action == "loadRewardedAd") {
|
646
683
|
val options = args.getJSONObject(0)
|
647
|
-
if(mActivity != null) {
|
684
|
+
if (mActivity != null) {
|
648
685
|
mActivity!!.runOnUiThread {
|
649
686
|
val adUnitId = options.optString("adUnitId")
|
650
687
|
val autoShow = options.optBoolean("autoShow")
|
@@ -664,8 +701,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
664
701
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
665
702
|
|
666
703
|
|
667
|
-
val responseId =
|
668
|
-
|
704
|
+
val responseId =
|
705
|
+
loadAdError.responseInfo?.responseId.toString()
|
706
|
+
val responseExtras =
|
707
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
669
708
|
val loadedAdapterResponseInfo =
|
670
709
|
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
671
710
|
val mediationAdapterClassName =
|
@@ -676,7 +715,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
676
715
|
put("responseInfoId", responseId)
|
677
716
|
put("responseInfoExtras", responseExtras)
|
678
717
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
679
|
-
put(
|
718
|
+
put(
|
719
|
+
"responseInfoMediationAdapterClassName",
|
720
|
+
mediationAdapterClassName
|
721
|
+
)
|
680
722
|
put("responseInfoAdapterResponses", adapterResponses)
|
681
723
|
|
682
724
|
|
@@ -755,7 +797,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
755
797
|
|
756
798
|
private val isRewardedAutoShow: Unit
|
757
799
|
get() {
|
758
|
-
if (mActivity != null){
|
800
|
+
if (mActivity != null) {
|
759
801
|
mActivity!!.runOnUiThread {
|
760
802
|
if (isRewardedLoad && rewardedAd != null) {
|
761
803
|
isAdSkip = 1
|
@@ -787,7 +829,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
787
829
|
}
|
788
830
|
return true
|
789
831
|
} else if (action == "showRewardedAd") {
|
790
|
-
if(mActivity != null && isRewardedLoad && rewardedAd != null) {
|
832
|
+
if (mActivity != null && isRewardedLoad && rewardedAd != null) {
|
791
833
|
mActivity!!.runOnUiThread {
|
792
834
|
isAdSkip = 1
|
793
835
|
rewardedAd!!.show(mActivity!!) { rewardItem: RewardItem ->
|
@@ -814,7 +856,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
814
856
|
return true
|
815
857
|
} else if (action == "loadRewardedInterstitialAd") {
|
816
858
|
val options = args.getJSONObject(0)
|
817
|
-
if(mActivity != null) {
|
859
|
+
if (mActivity != null) {
|
818
860
|
mActivity!!.runOnUiThread {
|
819
861
|
val adUnitId = options.optString("adUnitId")
|
820
862
|
val autoShow = options.optBoolean("autoShow")
|
@@ -888,12 +930,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
888
930
|
}
|
889
931
|
|
890
932
|
|
891
|
-
|
892
|
-
|
893
933
|
}
|
894
934
|
|
895
935
|
|
896
|
-
|
897
936
|
private val isRIntAutoShow: Unit
|
898
937
|
get() {
|
899
938
|
if (mActivity !== null) {
|
@@ -930,8 +969,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
930
969
|
put("domain", loadAdError.domain)
|
931
970
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
932
971
|
|
933
|
-
val responseId =
|
934
|
-
|
972
|
+
val responseId =
|
973
|
+
loadAdError.responseInfo?.responseId.toString()
|
974
|
+
val responseExtras =
|
975
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
935
976
|
val loadedAdapterResponseInfo =
|
936
977
|
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
937
978
|
val mediationAdapterClassName =
|
@@ -942,7 +983,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
942
983
|
put("responseInfoId", responseId)
|
943
984
|
put("responseInfoExtras", responseExtras)
|
944
985
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
945
|
-
put(
|
986
|
+
put(
|
987
|
+
"responseInfoMediationAdapterClassName",
|
988
|
+
mediationAdapterClassName
|
989
|
+
)
|
946
990
|
put("responseInfoAdapterResponses", adapterResponses)
|
947
991
|
}
|
948
992
|
cWebView!!.loadUrl(
|
@@ -958,7 +1002,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
958
1002
|
}
|
959
1003
|
return true
|
960
1004
|
} else if (action == "showRewardedInterstitialAd") {
|
961
|
-
if(mActivity != null) {
|
1005
|
+
if (mActivity != null) {
|
962
1006
|
mActivity!!.runOnUiThread {
|
963
1007
|
if (isRewardedInterstitialLoad && rewardedInterstitialAd != null) {
|
964
1008
|
isAdSkip = 1
|
@@ -986,7 +1030,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
986
1030
|
}
|
987
1031
|
return true
|
988
1032
|
} else if (action == "showPrivacyOptionsForm") {
|
989
|
-
if(mActivity != null) {
|
1033
|
+
if (mActivity != null) {
|
990
1034
|
mActivity!!.runOnUiThread {
|
991
1035
|
try {
|
992
1036
|
val params: ConsentRequestParameters
|
@@ -1051,7 +1095,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1051
1095
|
}
|
1052
1096
|
return true
|
1053
1097
|
} else if (action == "consentReset") {
|
1054
|
-
if(mActivity != null) {
|
1098
|
+
if (mActivity != null) {
|
1055
1099
|
mActivity!!.runOnUiThread {
|
1056
1100
|
try {
|
1057
1101
|
consentInformation!!.reset()
|
@@ -1062,7 +1106,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1062
1106
|
}
|
1063
1107
|
return true
|
1064
1108
|
} else if (action == "getIabTfc") {
|
1065
|
-
if(mActivity != null) {
|
1109
|
+
if (mActivity != null) {
|
1066
1110
|
mActivity!!.runOnUiThread {
|
1067
1111
|
val gdprApplies = mPreferences!!.getInt("IABTCF_gdprApplies", 0)
|
1068
1112
|
val purposeConsents = mPreferences!!.getString("IABTCF_PurposeConsents", "")
|
@@ -1090,7 +1134,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1090
1134
|
}
|
1091
1135
|
return true
|
1092
1136
|
} else if (action == "loadBannerAd") {
|
1093
|
-
if(mActivity != null) {
|
1137
|
+
if (mActivity != null) {
|
1094
1138
|
val options = args.getJSONObject(0)
|
1095
1139
|
mActivity!!.runOnUiThread {
|
1096
1140
|
val adUnitId = options.optString("adUnitId")
|
@@ -1116,7 +1160,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1116
1160
|
}
|
1117
1161
|
return true
|
1118
1162
|
} else if (action == "showBannerAd") {
|
1119
|
-
if(mActivity != null) {
|
1163
|
+
if (mActivity != null) {
|
1120
1164
|
mActivity!!.runOnUiThread {
|
1121
1165
|
if (isBannerPause == 0) {
|
1122
1166
|
isShowBannerAds
|
@@ -1126,7 +1170,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1126
1170
|
bannerView!!.resume()
|
1127
1171
|
|
1128
1172
|
if (isOverlapping) {
|
1129
|
-
|
1173
|
+
bannerOverlapping()
|
1130
1174
|
}
|
1131
1175
|
|
1132
1176
|
bannerViewLayout!!.requestFocus();
|
@@ -1141,7 +1185,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1141
1185
|
return true
|
1142
1186
|
} else if (action == "styleBannerAd") {
|
1143
1187
|
val options = args.getJSONObject(0)
|
1144
|
-
if(mActivity != null) {
|
1188
|
+
if (mActivity != null) {
|
1145
1189
|
mActivity!!.runOnUiThread {
|
1146
1190
|
val isOverlapping = options.optBoolean("isOverlapping")
|
1147
1191
|
val overlappingHeight = options.optInt("overlappingHeight")
|
@@ -1160,7 +1204,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1160
1204
|
return true
|
1161
1205
|
} else if (action == "collapsibleBannerAd") {
|
1162
1206
|
val options = args.getJSONObject(0)
|
1163
|
-
if(mActivity != null) {
|
1207
|
+
if (mActivity != null) {
|
1164
1208
|
mActivity!!.runOnUiThread {
|
1165
1209
|
val enableCollapsible = options.optBoolean("enabledBannerCollapsible")
|
1166
1210
|
val collapsible = options.optString("collapsiblePosition")
|
@@ -1174,7 +1218,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1174
1218
|
}
|
1175
1219
|
return true
|
1176
1220
|
} else if (action == "hideBannerAd") {
|
1177
|
-
if(mActivity != null) {
|
1221
|
+
if (mActivity != null) {
|
1178
1222
|
mActivity!!.runOnUiThread {
|
1179
1223
|
if (isBannerShow) {
|
1180
1224
|
try {
|
@@ -1191,7 +1235,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1191
1235
|
}
|
1192
1236
|
return true
|
1193
1237
|
} else if (action == "removeBannerAd") {
|
1194
|
-
if(mActivity != null) {
|
1238
|
+
if (mActivity != null) {
|
1195
1239
|
mActivity!!.runOnUiThread {
|
1196
1240
|
try {
|
1197
1241
|
if (bannerViewLayout != null && bannerView != null) {
|
@@ -1211,11 +1255,70 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1211
1255
|
}
|
1212
1256
|
}
|
1213
1257
|
return true
|
1258
|
+
|
1259
|
+
} else if (action == "registerWebView") {
|
1260
|
+
if (mActivity != null) {
|
1261
|
+
mActivity!!.runOnUiThread {
|
1262
|
+
try {
|
1263
|
+
registerWebView(callbackContext)
|
1264
|
+
} catch (e: Exception) {
|
1265
|
+
PUBLIC_CALLBACKS!!.error("Error register WebView: " + e.message)
|
1266
|
+
}
|
1267
|
+
}
|
1268
|
+
}
|
1269
|
+
return true
|
1270
|
+
} else if (action == "loadUrl") {
|
1271
|
+
val options = args.getJSONObject(0)
|
1272
|
+
if (mActivity != null) {
|
1273
|
+
val url = options.optString("url")
|
1274
|
+
mActivity!!.runOnUiThread {
|
1275
|
+
try {
|
1276
|
+
loadUrl(url, callbackContext)
|
1277
|
+
} catch (e: Exception) {
|
1278
|
+
PUBLIC_CALLBACKS!!.error("Error load Url: " + e.message)
|
1279
|
+
}
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
}
|
1283
|
+
return true
|
1214
1284
|
}
|
1215
1285
|
return false
|
1216
1286
|
}
|
1217
1287
|
|
1218
1288
|
|
1289
|
+
private fun registerWebView(callbackContext: CallbackContext) {
|
1290
|
+
try {
|
1291
|
+
val webView = cWebView?.view
|
1292
|
+
if (webView is WebView) {
|
1293
|
+
MobileAds.registerWebView(webView)
|
1294
|
+
callbackContext.success("WebView registered successfully")
|
1295
|
+
} else {
|
1296
|
+
callbackContext.error("View is not a WebView.")
|
1297
|
+
}
|
1298
|
+
} catch (e: Exception) {
|
1299
|
+
callbackContext.error("Error registering WebView: ${e.message}")
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
|
1305
|
+
private fun loadUrl(url: String, callbackContext: CallbackContext) {
|
1306
|
+
try {
|
1307
|
+
val webView = cWebView?.view
|
1308
|
+
|
1309
|
+
if (webView is WebView) {
|
1310
|
+
webView.loadUrl(url)
|
1311
|
+
callbackContext.success("URL loaded successfully: $url")
|
1312
|
+
} else {
|
1313
|
+
callbackContext.error("WebView is not available.")
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
} catch (e: Exception) {
|
1317
|
+
callbackContext.error("Error loading URL: ${e.message}")
|
1318
|
+
}
|
1319
|
+
}
|
1320
|
+
|
1321
|
+
|
1219
1322
|
|
1220
1323
|
private fun loadBannerAd(adUnitId: String, position: String, size: String) {
|
1221
1324
|
try {
|
@@ -2172,3 +2275,5 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2172
2275
|
}
|
2173
2276
|
|
2174
2277
|
|
2278
|
+
|
2279
|
+
|
package/www/emiAdmobPlugin.js
CHANGED
@@ -3,6 +3,12 @@ var exec = require('cordova/exec');
|
|
3
3
|
exports.initialize = function (options, success, error) {
|
4
4
|
exec(success, error, 'emiAdmobPlugin', 'initialize', [options]);
|
5
5
|
};
|
6
|
+
exports.registerWebView = function (success, error) {
|
7
|
+
exec(success, error, 'emiAdmobPlugin', 'registerWebView', []);
|
8
|
+
};
|
9
|
+
exports.loadUrl = function (options, success, error) {
|
10
|
+
exec(success, error, 'emiAdmobPlugin', 'loadUrl', [options]);
|
11
|
+
};
|
6
12
|
exports.loadAppOpenAd = function (options, success, error) {
|
7
13
|
exec(success, error, 'emiAdmobPlugin', 'loadAppOpenAd', [options]);
|
8
14
|
};
|