emi-indo-cordova-plugin-admob 1.6.5 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +2 -2
- package/README.md +8 -9
- package/example/www/index.html +4 -0
- package/example/www/js/adSense.js +44 -0
- package/package.json +5 -2
- package/plugin.xml +8 -2
- package/src/android/emiAdmobPlugin.kt +183 -80
- package/www/emiAdmobPlugin.js +9 -0
package/.github/FUNDING.yml
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4
4
|
patreon: # Replace with a single Patreon username
|
5
5
|
open_collective: # Replace with a single Open Collective username
|
6
|
-
ko_fi:
|
7
|
-
tidelift:
|
6
|
+
ko_fi: emiindo
|
7
|
+
tidelift: # npm/emi-indo-cordova-plugin-admob
|
8
8
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9
9
|
liberapay: # Replace with a single Liberapay username
|
10
10
|
issuehunt: # Replace with a single IssueHunt username
|
package/README.md
CHANGED
@@ -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)
|
@@ -102,7 +102,7 @@ https://developers.google.com/admob/ios/quick-start
|
|
102
102
|
|
103
103
|
## 💰Sponsor this project
|
104
104
|
[](https://paypal.me/emiindo)
|
105
|
-
|
105
|
+
[](https://ko-fi.com/F1F16NI8H)
|
106
106
|
## [Check all release notes:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/)
|
107
107
|
|
108
108
|
|
@@ -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.7",
|
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.7">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova Plugin Admob Android IOS</description>
|
@@ -40,7 +40,10 @@
|
|
40
40
|
<uses-permission android:name="android.permission.INTERNET" />
|
41
41
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
42
42
|
</config-file>
|
43
|
-
|
43
|
+
|
44
|
+
<config-file parent="./application" target="AndroidManifest.xml">
|
45
|
+
<property android:name="android.adservices.AD_SERVICES_CONFIG" android:resource="@xml/gma_ad_services_config" tools:replace="android:resource" />
|
46
|
+
</config-file>
|
44
47
|
|
45
48
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
46
49
|
<activity
|
@@ -56,6 +59,9 @@
|
|
56
59
|
android:value="true" />
|
57
60
|
<meta-data android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
|
58
61
|
android:value="true" />
|
62
|
+
<meta-data
|
63
|
+
android:name="com.google.android.gms.ads.INTEGRATION_MANAGER"
|
64
|
+
android:value="webview"/>
|
59
65
|
</config-file>
|
60
66
|
|
61
67
|
<!-- 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
|
*/
|
@@ -136,6 +138,8 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
136
138
|
|
137
139
|
private var isUsingAdManagerRequest = false
|
138
140
|
|
141
|
+
private var isCustomConsentManager = false
|
142
|
+
|
139
143
|
|
140
144
|
override fun initialize(cordova: CordovaInterface, webView: CordovaWebView) {
|
141
145
|
super.initialize(cordova, webView)
|
@@ -224,7 +228,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
224
228
|
|
225
229
|
if (action == "initialize") {
|
226
230
|
val options = args.getJSONObject(0)
|
227
|
-
if(mActivity != null) {
|
231
|
+
if (mActivity != null) {
|
228
232
|
mActivity!!.runOnUiThread {
|
229
233
|
val setAdRequest = options.optBoolean("isUsingAdManagerRequest")
|
230
234
|
val responseInfo = options.optBoolean("isResponseInfo")
|
@@ -232,6 +236,14 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
232
236
|
setUsingAdManagerRequest(setAdRequest)
|
233
237
|
this.isResponseInfo = responseInfo
|
234
238
|
this.setDebugGeography = setDebugGeography
|
239
|
+
|
240
|
+
// If the user uses a custom CMP
|
241
|
+
if (this.isCustomConsentManager) {
|
242
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.custom.consent.manager.used');")
|
243
|
+
initializeMobileAdsSdk()
|
244
|
+
return@runOnUiThread
|
245
|
+
}
|
246
|
+
|
235
247
|
val params: ConsentRequestParameters
|
236
248
|
if (this.setDebugGeography) {
|
237
249
|
val debugSettings = mActivity?.let {
|
@@ -289,7 +301,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
289
301
|
return true
|
290
302
|
} else if (action == "targeting") {
|
291
303
|
val options = args.getJSONObject(0)
|
292
|
-
if(mActivity != null) {
|
304
|
+
if (mActivity != null) {
|
293
305
|
mActivity!!.runOnUiThread {
|
294
306
|
try {
|
295
307
|
val childDirectedTreatment = options.optBoolean("childDirectedTreatment")
|
@@ -308,7 +320,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
308
320
|
return true
|
309
321
|
} else if (action == "targetingAdRequest") {
|
310
322
|
val options = args.getJSONObject(0)
|
311
|
-
if(mActivity != null) {
|
323
|
+
if (mActivity != null) {
|
312
324
|
mActivity!!.runOnUiThread {
|
313
325
|
val customTargetingEnabled = options.optBoolean("customTargetingEnabled")
|
314
326
|
val categoryExclusionsEnabled = options.optBoolean("categoryExclusionsEnabled")
|
@@ -346,7 +358,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
346
358
|
return true
|
347
359
|
} else if (action == "setPersonalizationState") {
|
348
360
|
val options = args.getJSONObject(0)
|
349
|
-
if(mActivity != null) {
|
361
|
+
if (mActivity != null) {
|
350
362
|
mActivity!!.runOnUiThread {
|
351
363
|
val setPPT = options.optString("setPersonalizationState")
|
352
364
|
try {
|
@@ -360,7 +372,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
360
372
|
return true
|
361
373
|
} else if (action == "setPPS") {
|
362
374
|
val options = args.getJSONObject(0)
|
363
|
-
if(mActivity != null) {
|
375
|
+
if (mActivity != null) {
|
364
376
|
mActivity!!.runOnUiThread {
|
365
377
|
val ppsEnabled = options.optBoolean("ppsEnabled")
|
366
378
|
val iabContent = options.optString("iabContent")
|
@@ -378,7 +390,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
378
390
|
return true
|
379
391
|
} else if (action == "globalSettings") {
|
380
392
|
val options = args.getJSONObject(0)
|
381
|
-
if(mActivity != null) {
|
393
|
+
if (mActivity != null) {
|
382
394
|
mActivity!!.runOnUiThread {
|
383
395
|
val setAppMuted = options.optBoolean("setAppMuted")
|
384
396
|
val setAppVolume = options.optInt("setAppVolume").toFloat()
|
@@ -393,7 +405,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
393
405
|
return true
|
394
406
|
} else if (action == "loadAppOpenAd") {
|
395
407
|
val options = args.getJSONObject(0)
|
396
|
-
if(mActivity != null) {
|
408
|
+
if (mActivity != null) {
|
397
409
|
mActivity!!.runOnUiThread {
|
398
410
|
val adUnitId = options.optString("adUnitId")
|
399
411
|
val autoShow = options.optBoolean("autoShow")
|
@@ -443,7 +455,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
443
455
|
val result = JSONObject()
|
444
456
|
val responseInfo = ad.responseInfo
|
445
457
|
try {
|
446
|
-
result.put(
|
458
|
+
result.put(
|
459
|
+
"getResponseId",
|
460
|
+
responseInfo.responseId.toString()
|
461
|
+
)
|
447
462
|
result.put(
|
448
463
|
"getAdapterResponses",
|
449
464
|
responseInfo.adapterResponses.toString()
|
@@ -481,14 +496,34 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
481
496
|
PUBLIC_CALLBACKS!!.error(e.toString())
|
482
497
|
}
|
483
498
|
}
|
499
|
+
|
484
500
|
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
|
485
501
|
isAppOpenAdShow = false
|
486
502
|
val errorData = JSONObject().apply {
|
487
|
-
put("responseInfo", loadAdError.responseInfo.toString())
|
488
503
|
put("code", loadAdError.code)
|
489
504
|
put("message", loadAdError.message)
|
490
505
|
put("domain", loadAdError.domain)
|
491
506
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
507
|
+
|
508
|
+
val responseId =
|
509
|
+
loadAdError.responseInfo?.responseId.toString()
|
510
|
+
val responseExtras =
|
511
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
512
|
+
val loadedAdapterResponseInfo =
|
513
|
+
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
514
|
+
val mediationAdapterClassName =
|
515
|
+
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
516
|
+
val adapterResponses =
|
517
|
+
loadAdError.responseInfo?.adapterResponses.toString()
|
518
|
+
|
519
|
+
put("responseInfoId", responseId)
|
520
|
+
put("responseInfoExtras", responseExtras)
|
521
|
+
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
522
|
+
put(
|
523
|
+
"responseInfoMediationAdapterClassName",
|
524
|
+
mediationAdapterClassName
|
525
|
+
)
|
526
|
+
put("responseInfoAdapterResponses", adapterResponses)
|
492
527
|
}
|
493
528
|
cWebView?.loadUrl(
|
494
529
|
"javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded', ${errorData});"
|
@@ -496,7 +531,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
496
531
|
}
|
497
532
|
|
498
533
|
})
|
499
|
-
|
534
|
+
} catch (e: Exception) {
|
500
535
|
callbackContext.error(e.toString())
|
501
536
|
}
|
502
537
|
}
|
@@ -518,7 +553,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
518
553
|
return true
|
519
554
|
} else if (action == "loadInterstitialAd") {
|
520
555
|
val options = args.getJSONObject(0)
|
521
|
-
if(mActivity != null) {
|
556
|
+
if (mActivity != null) {
|
522
557
|
mActivity!!.runOnUiThread {
|
523
558
|
val adUnitId = options.optString("adUnitId")
|
524
559
|
val autoShow = options.optBoolean("autoShow")
|
@@ -550,7 +585,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
550
585
|
"getAdapterResponses",
|
551
586
|
responseInfo.adapterResponses
|
552
587
|
)
|
553
|
-
result.put(
|
588
|
+
result.put(
|
589
|
+
"getResponseExtras",
|
590
|
+
responseInfo.responseExtras
|
591
|
+
)
|
554
592
|
result.put(
|
555
593
|
"getMediationAdapterClassName",
|
556
594
|
responseInfo.mediationAdapterClassName
|
@@ -590,7 +628,11 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
590
628
|
private val isIntAutoShow: Unit
|
591
629
|
get() {
|
592
630
|
if (mActivity != null && isInterstitialLoad && mInterstitialAd != null) {
|
593
|
-
mActivity!!.runOnUiThread {
|
631
|
+
mActivity!!.runOnUiThread {
|
632
|
+
mInterstitialAd!!.show(
|
633
|
+
mActivity!!
|
634
|
+
)
|
635
|
+
}
|
594
636
|
}
|
595
637
|
}
|
596
638
|
|
@@ -604,8 +646,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
604
646
|
put("domain", loadAdError.domain)
|
605
647
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
606
648
|
|
607
|
-
val responseId =
|
608
|
-
|
649
|
+
val responseId =
|
650
|
+
loadAdError.responseInfo?.responseId.toString()
|
651
|
+
val responseExtras =
|
652
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
609
653
|
val loadedAdapterResponseInfo =
|
610
654
|
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
611
655
|
val mediationAdapterClassName =
|
@@ -616,7 +660,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
616
660
|
put("responseInfoId", responseId)
|
617
661
|
put("responseInfoExtras", responseExtras)
|
618
662
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
619
|
-
put(
|
663
|
+
put(
|
664
|
+
"responseInfoMediationAdapterClassName",
|
665
|
+
mediationAdapterClassName
|
666
|
+
)
|
620
667
|
put("responseInfoAdapterResponses", adapterResponses)
|
621
668
|
}
|
622
669
|
|
@@ -644,7 +691,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
644
691
|
return true
|
645
692
|
} else if (action == "loadRewardedAd") {
|
646
693
|
val options = args.getJSONObject(0)
|
647
|
-
if(mActivity != null) {
|
694
|
+
if (mActivity != null) {
|
648
695
|
mActivity!!.runOnUiThread {
|
649
696
|
val adUnitId = options.optString("adUnitId")
|
650
697
|
val autoShow = options.optBoolean("autoShow")
|
@@ -664,8 +711,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
664
711
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
665
712
|
|
666
713
|
|
667
|
-
val responseId =
|
668
|
-
|
714
|
+
val responseId =
|
715
|
+
loadAdError.responseInfo?.responseId.toString()
|
716
|
+
val responseExtras =
|
717
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
669
718
|
val loadedAdapterResponseInfo =
|
670
719
|
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
671
720
|
val mediationAdapterClassName =
|
@@ -676,7 +725,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
676
725
|
put("responseInfoId", responseId)
|
677
726
|
put("responseInfoExtras", responseExtras)
|
678
727
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
679
|
-
put(
|
728
|
+
put(
|
729
|
+
"responseInfoMediationAdapterClassName",
|
730
|
+
mediationAdapterClassName
|
731
|
+
)
|
680
732
|
put("responseInfoAdapterResponses", adapterResponses)
|
681
733
|
|
682
734
|
|
@@ -755,7 +807,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
755
807
|
|
756
808
|
private val isRewardedAutoShow: Unit
|
757
809
|
get() {
|
758
|
-
if (mActivity != null){
|
810
|
+
if (mActivity != null) {
|
759
811
|
mActivity!!.runOnUiThread {
|
760
812
|
if (isRewardedLoad && rewardedAd != null) {
|
761
813
|
isAdSkip = 1
|
@@ -787,7 +839,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
787
839
|
}
|
788
840
|
return true
|
789
841
|
} else if (action == "showRewardedAd") {
|
790
|
-
if(mActivity != null && isRewardedLoad && rewardedAd != null) {
|
842
|
+
if (mActivity != null && isRewardedLoad && rewardedAd != null) {
|
791
843
|
mActivity!!.runOnUiThread {
|
792
844
|
isAdSkip = 1
|
793
845
|
rewardedAd!!.show(mActivity!!) { rewardItem: RewardItem ->
|
@@ -814,7 +866,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
814
866
|
return true
|
815
867
|
} else if (action == "loadRewardedInterstitialAd") {
|
816
868
|
val options = args.getJSONObject(0)
|
817
|
-
if(mActivity != null) {
|
869
|
+
if (mActivity != null) {
|
818
870
|
mActivity!!.runOnUiThread {
|
819
871
|
val adUnitId = options.optString("adUnitId")
|
820
872
|
val autoShow = options.optBoolean("autoShow")
|
@@ -888,12 +940,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
888
940
|
}
|
889
941
|
|
890
942
|
|
891
|
-
|
892
|
-
|
893
943
|
}
|
894
944
|
|
895
945
|
|
896
|
-
|
897
946
|
private val isRIntAutoShow: Unit
|
898
947
|
get() {
|
899
948
|
if (mActivity !== null) {
|
@@ -930,8 +979,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
930
979
|
put("domain", loadAdError.domain)
|
931
980
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
932
981
|
|
933
|
-
val responseId =
|
934
|
-
|
982
|
+
val responseId =
|
983
|
+
loadAdError.responseInfo?.responseId.toString()
|
984
|
+
val responseExtras =
|
985
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
935
986
|
val loadedAdapterResponseInfo =
|
936
987
|
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
937
988
|
val mediationAdapterClassName =
|
@@ -942,7 +993,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
942
993
|
put("responseInfoId", responseId)
|
943
994
|
put("responseInfoExtras", responseExtras)
|
944
995
|
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
945
|
-
put(
|
996
|
+
put(
|
997
|
+
"responseInfoMediationAdapterClassName",
|
998
|
+
mediationAdapterClassName
|
999
|
+
)
|
946
1000
|
put("responseInfoAdapterResponses", adapterResponses)
|
947
1001
|
}
|
948
1002
|
cWebView!!.loadUrl(
|
@@ -958,7 +1012,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
958
1012
|
}
|
959
1013
|
return true
|
960
1014
|
} else if (action == "showRewardedInterstitialAd") {
|
961
|
-
if(mActivity != null) {
|
1015
|
+
if (mActivity != null) {
|
962
1016
|
mActivity!!.runOnUiThread {
|
963
1017
|
if (isRewardedInterstitialLoad && rewardedInterstitialAd != null) {
|
964
1018
|
isAdSkip = 1
|
@@ -986,7 +1040,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
986
1040
|
}
|
987
1041
|
return true
|
988
1042
|
} else if (action == "showPrivacyOptionsForm") {
|
989
|
-
if(mActivity != null) {
|
1043
|
+
if (mActivity != null) {
|
990
1044
|
mActivity!!.runOnUiThread {
|
991
1045
|
try {
|
992
1046
|
val params: ConsentRequestParameters
|
@@ -1051,7 +1105,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1051
1105
|
}
|
1052
1106
|
return true
|
1053
1107
|
} else if (action == "consentReset") {
|
1054
|
-
if(mActivity != null) {
|
1108
|
+
if (mActivity != null) {
|
1055
1109
|
mActivity!!.runOnUiThread {
|
1056
1110
|
try {
|
1057
1111
|
consentInformation!!.reset()
|
@@ -1062,7 +1116,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1062
1116
|
}
|
1063
1117
|
return true
|
1064
1118
|
} else if (action == "getIabTfc") {
|
1065
|
-
if(mActivity != null) {
|
1119
|
+
if (mActivity != null) {
|
1066
1120
|
mActivity!!.runOnUiThread {
|
1067
1121
|
val gdprApplies = mPreferences!!.getInt("IABTCF_gdprApplies", 0)
|
1068
1122
|
val purposeConsents = mPreferences!!.getString("IABTCF_PurposeConsents", "")
|
@@ -1090,7 +1144,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1090
1144
|
}
|
1091
1145
|
return true
|
1092
1146
|
} else if (action == "loadBannerAd") {
|
1093
|
-
if(mActivity != null) {
|
1147
|
+
if (mActivity != null) {
|
1094
1148
|
val options = args.getJSONObject(0)
|
1095
1149
|
mActivity!!.runOnUiThread {
|
1096
1150
|
val adUnitId = options.optString("adUnitId")
|
@@ -1116,7 +1170,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1116
1170
|
}
|
1117
1171
|
return true
|
1118
1172
|
} else if (action == "showBannerAd") {
|
1119
|
-
if(mActivity != null) {
|
1173
|
+
if (mActivity != null) {
|
1120
1174
|
mActivity!!.runOnUiThread {
|
1121
1175
|
if (isBannerPause == 0) {
|
1122
1176
|
isShowBannerAds
|
@@ -1126,7 +1180,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1126
1180
|
bannerView!!.resume()
|
1127
1181
|
|
1128
1182
|
if (isOverlapping) {
|
1129
|
-
|
1183
|
+
bannerOverlapping()
|
1130
1184
|
}
|
1131
1185
|
|
1132
1186
|
bannerViewLayout!!.requestFocus();
|
@@ -1141,7 +1195,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1141
1195
|
return true
|
1142
1196
|
} else if (action == "styleBannerAd") {
|
1143
1197
|
val options = args.getJSONObject(0)
|
1144
|
-
if(mActivity != null) {
|
1198
|
+
if (mActivity != null) {
|
1145
1199
|
mActivity!!.runOnUiThread {
|
1146
1200
|
val isOverlapping = options.optBoolean("isOverlapping")
|
1147
1201
|
val overlappingHeight = options.optInt("overlappingHeight")
|
@@ -1158,23 +1212,15 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1158
1212
|
}
|
1159
1213
|
}
|
1160
1214
|
return true
|
1161
|
-
} else if (action == "
|
1215
|
+
} else if (action == "metaData") {
|
1162
1216
|
val options = args.getJSONObject(0)
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
val collapsible = options.optString("collapsiblePosition")
|
1167
|
-
try {
|
1168
|
-
this.isCollapsible = enableCollapsible
|
1169
|
-
this.collapsiblePos = collapsible
|
1170
|
-
} catch (e: Exception) {
|
1171
|
-
callbackContext.error(e.toString())
|
1172
|
-
}
|
1173
|
-
}
|
1217
|
+
val useCustomConsentManager = options.optBoolean("useCustomConsentManager")
|
1218
|
+
if (mActivity != null) {
|
1219
|
+
this.isCustomConsentManager = useCustomConsentManager
|
1174
1220
|
}
|
1175
1221
|
return true
|
1176
1222
|
} else if (action == "hideBannerAd") {
|
1177
|
-
if(mActivity != null) {
|
1223
|
+
if (mActivity != null) {
|
1178
1224
|
mActivity!!.runOnUiThread {
|
1179
1225
|
if (isBannerShow) {
|
1180
1226
|
try {
|
@@ -1191,7 +1237,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1191
1237
|
}
|
1192
1238
|
return true
|
1193
1239
|
} else if (action == "removeBannerAd") {
|
1194
|
-
if(mActivity != null) {
|
1240
|
+
if (mActivity != null) {
|
1195
1241
|
mActivity!!.runOnUiThread {
|
1196
1242
|
try {
|
1197
1243
|
if (bannerViewLayout != null && bannerView != null) {
|
@@ -1211,11 +1257,70 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1211
1257
|
}
|
1212
1258
|
}
|
1213
1259
|
return true
|
1260
|
+
|
1261
|
+
} else if (action == "registerWebView") {
|
1262
|
+
if (mActivity != null) {
|
1263
|
+
mActivity!!.runOnUiThread {
|
1264
|
+
try {
|
1265
|
+
registerWebView(callbackContext)
|
1266
|
+
} catch (e: Exception) {
|
1267
|
+
PUBLIC_CALLBACKS!!.error("Error register WebView: " + e.message)
|
1268
|
+
}
|
1269
|
+
}
|
1270
|
+
}
|
1271
|
+
return true
|
1272
|
+
} else if (action == "loadUrl") {
|
1273
|
+
val options = args.getJSONObject(0)
|
1274
|
+
if (mActivity != null) {
|
1275
|
+
val url = options.optString("url")
|
1276
|
+
mActivity!!.runOnUiThread {
|
1277
|
+
try {
|
1278
|
+
loadUrl(url, callbackContext)
|
1279
|
+
} catch (e: Exception) {
|
1280
|
+
PUBLIC_CALLBACKS!!.error("Error load Url: " + e.message)
|
1281
|
+
}
|
1282
|
+
}
|
1283
|
+
|
1284
|
+
}
|
1285
|
+
return true
|
1214
1286
|
}
|
1215
1287
|
return false
|
1216
1288
|
}
|
1217
1289
|
|
1218
1290
|
|
1291
|
+
private fun registerWebView(callbackContext: CallbackContext) {
|
1292
|
+
try {
|
1293
|
+
val webView = cWebView?.view
|
1294
|
+
if (webView is WebView) {
|
1295
|
+
MobileAds.registerWebView(webView)
|
1296
|
+
callbackContext.success("WebView registered successfully")
|
1297
|
+
} else {
|
1298
|
+
callbackContext.error("View is not a WebView.")
|
1299
|
+
}
|
1300
|
+
} catch (e: Exception) {
|
1301
|
+
callbackContext.error("Error registering WebView: ${e.message}")
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
|
1307
|
+
private fun loadUrl(url: String, callbackContext: CallbackContext) {
|
1308
|
+
try {
|
1309
|
+
val webView = cWebView?.view
|
1310
|
+
|
1311
|
+
if (webView is WebView) {
|
1312
|
+
webView.loadUrl(url)
|
1313
|
+
callbackContext.success("URL loaded successfully: $url")
|
1314
|
+
} else {
|
1315
|
+
callbackContext.error("WebView is not available.")
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
} catch (e: Exception) {
|
1319
|
+
callbackContext.error("Error loading URL: ${e.message}")
|
1320
|
+
}
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
|
1219
1324
|
|
1220
1325
|
private fun loadBannerAd(adUnitId: String, position: String, size: String) {
|
1221
1326
|
try {
|
@@ -1381,7 +1486,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1381
1486
|
put("responseInfoAdapterResponses", adapterResponses)
|
1382
1487
|
}
|
1383
1488
|
|
1384
|
-
|
1489
|
+
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
|
1385
1490
|
|
1386
1491
|
bannerOverlappingToZero()
|
1387
1492
|
|
@@ -1496,30 +1601,30 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1496
1601
|
|
1497
1602
|
|
1498
1603
|
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
}
|
1604
|
+
// fix https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/issues/26
|
1605
|
+
private fun bannerOverlapping() {
|
1606
|
+
if (bannerView != null && mActivity != null && cWebView != null) {
|
1607
|
+
mActivity!!.runOnUiThread {
|
1608
|
+
try {
|
1609
|
+
val bannerHeightInPx = bannerView!!.height
|
1610
|
+
val displayMetrics = DisplayMetrics()
|
1611
|
+
mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
|
1612
|
+
val screenHeightInPx = displayMetrics.heightPixels
|
1613
|
+
|
1614
|
+
// Adjust the WebView height to account for the banner ad
|
1615
|
+
val webViewHeight = screenHeightInPx - (adSize.height + overlappingHeight)
|
1616
|
+
val layoutParams = cWebView!!.view.layoutParams
|
1617
|
+
layoutParams.height = webViewHeight
|
1618
|
+
cWebView!!.view.layoutParams = layoutParams
|
1619
|
+
|
1620
|
+
// Log for debugging
|
1621
|
+
Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
|
1622
|
+
} catch (e: Exception) {
|
1623
|
+
Log.e("AdmobPlugin", "Error adjusting WebView for banner: ${e.message}")
|
1520
1624
|
}
|
1521
1625
|
}
|
1522
1626
|
}
|
1627
|
+
}
|
1523
1628
|
|
1524
1629
|
|
1525
1630
|
|
@@ -1682,7 +1787,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1682
1787
|
try {
|
1683
1788
|
(brandSafetyUrls as ArrayList<String>).add(brandSafetyArr.getString(i))
|
1684
1789
|
} catch (e: JSONException) {
|
1685
|
-
|
1790
|
+
e.printStackTrace();
|
1686
1791
|
}
|
1687
1792
|
}
|
1688
1793
|
}
|
@@ -1691,7 +1796,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1691
1796
|
this.ppIdVl = ppId
|
1692
1797
|
this.cURLVl = ctURL
|
1693
1798
|
} catch (e: JSONException) {
|
1694
|
-
|
1799
|
+
e.printStackTrace();
|
1695
1800
|
}
|
1696
1801
|
}
|
1697
1802
|
|
@@ -1705,7 +1810,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1705
1810
|
}
|
1706
1811
|
}
|
1707
1812
|
} catch (e: JSONException) {
|
1708
|
-
|
1813
|
+
e.printStackTrace();
|
1709
1814
|
}
|
1710
1815
|
}
|
1711
1816
|
|
@@ -1732,7 +1837,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1732
1837
|
}
|
1733
1838
|
}
|
1734
1839
|
val sdkVersion = MobileAds.getVersion().toString()
|
1735
|
-
val mStatus = consentInformation
|
1840
|
+
val mStatus = consentInformation?.consentStatus.toString()
|
1736
1841
|
|
1737
1842
|
val adapterInfo = StringBuilder()
|
1738
1843
|
for (adapterClass in statusMap.keys) {
|
@@ -2169,6 +2274,4 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2169
2274
|
private const val LAST_ACCESS_SUFFIX = "_last_access"
|
2170
2275
|
private const val EXPIRATION_TIME = 360L * 24 * 60 * 60 * 1000
|
2171
2276
|
}
|
2172
|
-
}
|
2173
|
-
|
2174
|
-
|
2277
|
+
}
|
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
|
};
|
@@ -67,6 +73,9 @@ exports.forceDisplayPrivacyForm = function (success, error) {
|
|
67
73
|
exec(success, error, 'emiAdmobPlugin', 'forceDisplayPrivacyForm', []); // only IOS
|
68
74
|
};
|
69
75
|
|
76
|
+
exports.metaData = function (options, success, error) {
|
77
|
+
exec(success, error, 'emiAdmobPlugin', 'metaData', [options]);
|
78
|
+
};
|
70
79
|
|
71
80
|
// ( only Android )
|
72
81
|
// only isUsingAdManagerRequest: true
|