emi-indo-cordova-plugin-admob 1.6.4 → 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 +16 -12
- package/example/www/index.html +5 -1
- package/example/www/js/adSense.js +44 -0
- package/example/www/js/appOpenAd.js +10 -1
- package/example/www/js/bannerAd.js +12 -0
- package/example/www/js/interstitialAd.js +11 -0
- package/example/www/js/rewardedAd.js +12 -1
- package/example/www/js/rewardedInterstitialAd.js +11 -0
- package/package.json +5 -2
- package/plugin.xml +4 -1
- package/src/android/emiAdmobPlugin.kt +213 -39
- 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)
|
@@ -125,9 +125,13 @@ https://developers.google.com/admob/ios/quick-start
|
|
125
125
|
<li> impression-level-ad-revenue</li>
|
126
126
|
</ul>
|
127
127
|
</details>
|
128
|
+
## Version locking the plugin during production is highly recommended.
|
128
129
|
|
129
|
-
|
130
|
+
- Example cordova plugin add emi-indo-cordova-plugin-admob@1.6.0 --save --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx
|
131
|
+
- View plugin version: https://www.npmjs.com/package/emi-indo-cordova-plugin-admob?activeTab=versions
|
132
|
+
- Release notes: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases
|
130
133
|
|
134
|
+
## Installation
|
131
135
|
- Only platform Android
|
132
136
|
```sh
|
133
137
|
cordova plugin add emi-indo-cordova-plugin-admob --save --variable APP_ID_ANDROID=ca-app-pub-xxx~xxx
|
@@ -170,7 +174,7 @@ cordova plugin rm emi-indo-cordova-plugin-admob
|
|
170
174
|
|
171
175
|
cordova.plugins.emiAdmobPlugin.initialize({
|
172
176
|
|
173
|
-
isUsingAdManagerRequest: true, // true =
|
177
|
+
isUsingAdManagerRequest: true, // true = AdManager | false = AdMob (Default true)
|
174
178
|
isResponseInfo: true, // Default false (Debug true)
|
175
179
|
isConsentDebug: true, // Default false (Debug true)
|
176
180
|
|
@@ -345,7 +349,7 @@ document.addEventListener('on.appOpenAd.loaded', () => {
|
|
345
349
|
</pre>
|
346
350
|
</details>
|
347
351
|
|
348
|
-
- [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/
|
352
|
+
- [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/appOpenAd.js)
|
349
353
|
|
350
354
|
|
351
355
|
|
@@ -448,7 +452,7 @@ console.log("Collapsible Status: " + event.collapsible);
|
|
448
452
|
</pre>
|
449
453
|
</details>
|
450
454
|
|
451
|
-
[FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/
|
455
|
+
[FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/bannerAd.js)
|
452
456
|
|
453
457
|
|
454
458
|
## Interstitial ADS
|
@@ -511,7 +515,7 @@ document.addEventListener('on.interstitial.dismissed', () => {
|
|
511
515
|
</details>
|
512
516
|
|
513
517
|
|
514
|
-
[FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/
|
518
|
+
[FULL Interstitial basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/interstitialAd.js)
|
515
519
|
|
516
520
|
|
517
521
|
|
@@ -640,7 +644,7 @@ document.addEventListener('on.rewarded.dismissed', () => {
|
|
640
644
|
</pre>
|
641
645
|
</details>
|
642
646
|
|
643
|
-
[FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/
|
647
|
+
[FULL Rewarded basic: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/rewardedAd.js)
|
644
648
|
|
645
649
|
|
646
650
|
|
package/example/www/index.html
CHANGED
@@ -7,12 +7,13 @@
|
|
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
|
|
13
14
|
|
14
15
|
<label for="event">Debug Event All response :</label>
|
15
|
-
<textarea id="log" name="log" rows="
|
16
|
+
<textarea id="log" name="log" rows="20" cols="40"></textarea>
|
16
17
|
|
17
18
|
<p> <button onclick="loadAppOpen();">Auto Show App Open Ad</button></p>
|
18
19
|
|
@@ -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
|
+
|
@@ -72,7 +72,16 @@ document.addEventListener('on.appOpenAd.loaded', () => {
|
|
72
72
|
document.addEventListener('on.appOpenAd.failed.loaded', (error) => {
|
73
73
|
isAppOpenAdLoad = false;
|
74
74
|
console.log("on.appOpenAd.failed.loaded" + JSON.stringify(error));
|
75
|
-
|
75
|
+
/*
|
76
|
+
error.code
|
77
|
+
error.message
|
78
|
+
error.domain
|
79
|
+
error.responseInfoId
|
80
|
+
error.responseInfoExtras
|
81
|
+
error.responseInfoAdapter
|
82
|
+
error.responseInfoMediationAdapterClassName
|
83
|
+
error.responseInfoAdapterResponses
|
84
|
+
*/
|
76
85
|
window.log.value += ("\n on.appOpenAd.failed.loaded" + JSON.stringify(error));
|
77
86
|
});
|
78
87
|
|
@@ -128,6 +128,18 @@ document.addEventListener('on.is.collapsible', function (event) {
|
|
128
128
|
|
129
129
|
document.addEventListener('on.banner.failed.load', (error) => {
|
130
130
|
console.log("on.banner.failed.load" + JSON.stringify(error));
|
131
|
+
|
132
|
+
/*
|
133
|
+
error.code
|
134
|
+
error.message
|
135
|
+
error.domain
|
136
|
+
error.responseInfoId
|
137
|
+
error.responseInfoExtras
|
138
|
+
error.responseInfoAdapter
|
139
|
+
error.responseInfoMediationAdapterClassName
|
140
|
+
error.responseInfoAdapterResponses
|
141
|
+
*/
|
142
|
+
|
131
143
|
});
|
132
144
|
|
133
145
|
|
@@ -67,6 +67,17 @@ document.addEventListener('on.interstitial.dismissed', () => {
|
|
67
67
|
document.addEventListener('on.interstitial.failed.load', (error) => {
|
68
68
|
isInterstitialLoad = false;
|
69
69
|
console.log("on.interstitial.failed.load" + JSON.stringify(error));
|
70
|
+
|
71
|
+
/*
|
72
|
+
error.code
|
73
|
+
error.message
|
74
|
+
error.domain
|
75
|
+
error.responseInfoId
|
76
|
+
error.responseInfoExtras
|
77
|
+
error.responseInfoAdapter
|
78
|
+
error.responseInfoMediationAdapterClassName
|
79
|
+
error.responseInfoAdapterResponses
|
80
|
+
*/
|
70
81
|
|
71
82
|
window.log.value += ("\n on.interstitial.failed.load" + JSON.stringify(error));
|
72
83
|
});
|
@@ -52,6 +52,17 @@ document.addEventListener('on.rewarded.failed.load', (error) => {
|
|
52
52
|
isRewardedLoad = false;
|
53
53
|
console.log("on.rewarded.failed.load" + JSON.stringify(error));
|
54
54
|
|
55
|
+
/*
|
56
|
+
error.code
|
57
|
+
error.message
|
58
|
+
error.domain
|
59
|
+
error.responseInfoId
|
60
|
+
error.responseInfoExtras
|
61
|
+
error.responseInfoAdapter
|
62
|
+
error.responseInfoMediationAdapterClassName
|
63
|
+
error.responseInfoAdapterResponses
|
64
|
+
*/
|
65
|
+
|
55
66
|
window.log.value += ("\n on.rewarded.failed.load" + JSON.stringify(error));
|
56
67
|
});
|
57
68
|
|
@@ -77,7 +88,7 @@ document.addEventListener('on.reward.userEarnedReward', (rewarded) => {
|
|
77
88
|
// all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
|
78
89
|
document.addEventListener('on.rewarded.dismissed', () => {
|
79
90
|
isRewardedLoad = false;
|
80
|
-
console.log("on
|
91
|
+
console.log("on rewarded Ad dismissed");
|
81
92
|
console.log("you can load ads automatically after the ads are closed by users");
|
82
93
|
loadRewarded();
|
83
94
|
|
@@ -50,6 +50,17 @@ document.addEventListener('on.rewardedInt.failed.load', (error) => {
|
|
50
50
|
isRewardedIntLoad = false;
|
51
51
|
console.log("on.rewardedInt.failed.load" + JSON.stringify(error));
|
52
52
|
|
53
|
+
/*
|
54
|
+
error.code
|
55
|
+
error.message
|
56
|
+
error.domain
|
57
|
+
error.responseInfoId
|
58
|
+
error.responseInfoExtras
|
59
|
+
error.responseInfoAdapter
|
60
|
+
error.responseInfoMediationAdapterClassName
|
61
|
+
error.responseInfoAdapterResponses
|
62
|
+
*/
|
63
|
+
|
53
64
|
window.log.value += ("\n on.rewardedInt.failed.load" + JSON.stringify(error));
|
54
65
|
});
|
55
66
|
|
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
|
*/
|
@@ -180,6 +182,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
180
182
|
bannerView!!.loadAd(buildAdRequest())
|
181
183
|
bannerViewLayout!!.addView(bannerView)
|
182
184
|
bannerViewLayout!!.bringToFront()
|
185
|
+
bannerViewLayout!!.requestFocus();
|
183
186
|
bannerOverlappingToZero()
|
184
187
|
}
|
185
188
|
} catch (e: Exception) {
|
@@ -223,7 +226,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
223
226
|
|
224
227
|
if (action == "initialize") {
|
225
228
|
val options = args.getJSONObject(0)
|
226
|
-
if(mActivity != null) {
|
229
|
+
if (mActivity != null) {
|
227
230
|
mActivity!!.runOnUiThread {
|
228
231
|
val setAdRequest = options.optBoolean("isUsingAdManagerRequest")
|
229
232
|
val responseInfo = options.optBoolean("isResponseInfo")
|
@@ -288,7 +291,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
288
291
|
return true
|
289
292
|
} else if (action == "targeting") {
|
290
293
|
val options = args.getJSONObject(0)
|
291
|
-
if(mActivity != null) {
|
294
|
+
if (mActivity != null) {
|
292
295
|
mActivity!!.runOnUiThread {
|
293
296
|
try {
|
294
297
|
val childDirectedTreatment = options.optBoolean("childDirectedTreatment")
|
@@ -307,7 +310,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
307
310
|
return true
|
308
311
|
} else if (action == "targetingAdRequest") {
|
309
312
|
val options = args.getJSONObject(0)
|
310
|
-
if(mActivity != null) {
|
313
|
+
if (mActivity != null) {
|
311
314
|
mActivity!!.runOnUiThread {
|
312
315
|
val customTargetingEnabled = options.optBoolean("customTargetingEnabled")
|
313
316
|
val categoryExclusionsEnabled = options.optBoolean("categoryExclusionsEnabled")
|
@@ -345,7 +348,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
345
348
|
return true
|
346
349
|
} else if (action == "setPersonalizationState") {
|
347
350
|
val options = args.getJSONObject(0)
|
348
|
-
if(mActivity != null) {
|
351
|
+
if (mActivity != null) {
|
349
352
|
mActivity!!.runOnUiThread {
|
350
353
|
val setPPT = options.optString("setPersonalizationState")
|
351
354
|
try {
|
@@ -359,7 +362,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
359
362
|
return true
|
360
363
|
} else if (action == "setPPS") {
|
361
364
|
val options = args.getJSONObject(0)
|
362
|
-
if(mActivity != null) {
|
365
|
+
if (mActivity != null) {
|
363
366
|
mActivity!!.runOnUiThread {
|
364
367
|
val ppsEnabled = options.optBoolean("ppsEnabled")
|
365
368
|
val iabContent = options.optString("iabContent")
|
@@ -377,7 +380,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
377
380
|
return true
|
378
381
|
} else if (action == "globalSettings") {
|
379
382
|
val options = args.getJSONObject(0)
|
380
|
-
if(mActivity != null) {
|
383
|
+
if (mActivity != null) {
|
381
384
|
mActivity!!.runOnUiThread {
|
382
385
|
val setAppMuted = options.optBoolean("setAppMuted")
|
383
386
|
val setAppVolume = options.optInt("setAppVolume").toFloat()
|
@@ -392,7 +395,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
392
395
|
return true
|
393
396
|
} else if (action == "loadAppOpenAd") {
|
394
397
|
val options = args.getJSONObject(0)
|
395
|
-
if(mActivity != null) {
|
398
|
+
if (mActivity != null) {
|
396
399
|
mActivity!!.runOnUiThread {
|
397
400
|
val adUnitId = options.optString("adUnitId")
|
398
401
|
val autoShow = options.optBoolean("autoShow")
|
@@ -437,28 +440,34 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
437
440
|
}
|
438
441
|
}
|
439
442
|
|
443
|
+
|
440
444
|
if (isResponseInfo) {
|
441
445
|
val result = JSONObject()
|
442
446
|
val responseInfo = ad.responseInfo
|
443
447
|
try {
|
444
|
-
result.put(
|
448
|
+
result.put(
|
449
|
+
"getResponseId",
|
450
|
+
responseInfo.responseId.toString()
|
451
|
+
)
|
445
452
|
result.put(
|
446
453
|
"getAdapterResponses",
|
447
|
-
responseInfo.adapterResponses
|
454
|
+
responseInfo.adapterResponses.toString()
|
448
455
|
)
|
449
456
|
result.put(
|
450
457
|
"getResponseExtras",
|
451
|
-
responseInfo.responseExtras
|
458
|
+
responseInfo.responseExtras.toString()
|
452
459
|
)
|
453
460
|
result.put(
|
454
461
|
"getMediationAdapterClassName",
|
455
|
-
responseInfo.mediationAdapterClassName
|
462
|
+
responseInfo.mediationAdapterClassName.toString()
|
456
463
|
)
|
457
464
|
result.put("getBundleExtra", mBundleExtra.toString())
|
458
465
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.responseInfo', ${result})")
|
459
466
|
} catch (e: JSONException) {
|
460
467
|
callbackContext.error(e.message)
|
461
468
|
}
|
469
|
+
|
470
|
+
|
462
471
|
}
|
463
472
|
|
464
473
|
|
@@ -477,14 +486,34 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
477
486
|
PUBLIC_CALLBACKS!!.error(e.toString())
|
478
487
|
}
|
479
488
|
}
|
489
|
+
|
480
490
|
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
|
481
491
|
isAppOpenAdShow = false
|
482
492
|
val errorData = JSONObject().apply {
|
483
|
-
put("responseInfo", loadAdError.responseInfo.toString())
|
484
493
|
put("code", loadAdError.code)
|
485
494
|
put("message", loadAdError.message)
|
486
495
|
put("domain", loadAdError.domain)
|
487
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)
|
488
517
|
}
|
489
518
|
cWebView?.loadUrl(
|
490
519
|
"javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded', ${errorData});"
|
@@ -492,7 +521,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
492
521
|
}
|
493
522
|
|
494
523
|
})
|
495
|
-
|
524
|
+
} catch (e: Exception) {
|
496
525
|
callbackContext.error(e.toString())
|
497
526
|
}
|
498
527
|
}
|
@@ -514,7 +543,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
514
543
|
return true
|
515
544
|
} else if (action == "loadInterstitialAd") {
|
516
545
|
val options = args.getJSONObject(0)
|
517
|
-
if(mActivity != null) {
|
546
|
+
if (mActivity != null) {
|
518
547
|
mActivity!!.runOnUiThread {
|
519
548
|
val adUnitId = options.optString("adUnitId")
|
520
549
|
val autoShow = options.optBoolean("autoShow")
|
@@ -546,7 +575,10 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
546
575
|
"getAdapterResponses",
|
547
576
|
responseInfo.adapterResponses
|
548
577
|
)
|
549
|
-
result.put(
|
578
|
+
result.put(
|
579
|
+
"getResponseExtras",
|
580
|
+
responseInfo.responseExtras
|
581
|
+
)
|
550
582
|
result.put(
|
551
583
|
"getMediationAdapterClassName",
|
552
584
|
responseInfo.mediationAdapterClassName
|
@@ -586,20 +618,46 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
586
618
|
private val isIntAutoShow: Unit
|
587
619
|
get() {
|
588
620
|
if (mActivity != null && isInterstitialLoad && mInterstitialAd != null) {
|
589
|
-
mActivity!!.runOnUiThread {
|
621
|
+
mActivity!!.runOnUiThread {
|
622
|
+
mInterstitialAd!!.show(
|
623
|
+
mActivity!!
|
624
|
+
)
|
625
|
+
}
|
590
626
|
}
|
591
627
|
}
|
592
628
|
|
593
629
|
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
|
594
630
|
mInterstitialAd = null
|
595
631
|
isInterstitialLoad = false
|
632
|
+
|
596
633
|
val errorData = JSONObject().apply {
|
597
|
-
put("responseInfo", loadAdError.responseInfo.toString())
|
598
634
|
put("code", loadAdError.code)
|
599
635
|
put("message", loadAdError.message)
|
600
636
|
put("domain", loadAdError.domain)
|
601
637
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
638
|
+
|
639
|
+
val responseId =
|
640
|
+
loadAdError.responseInfo?.responseId.toString()
|
641
|
+
val responseExtras =
|
642
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
643
|
+
val loadedAdapterResponseInfo =
|
644
|
+
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
645
|
+
val mediationAdapterClassName =
|
646
|
+
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
647
|
+
val adapterResponses =
|
648
|
+
loadAdError.responseInfo?.adapterResponses.toString()
|
649
|
+
|
650
|
+
put("responseInfoId", responseId)
|
651
|
+
put("responseInfoExtras", responseExtras)
|
652
|
+
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
653
|
+
put(
|
654
|
+
"responseInfoMediationAdapterClassName",
|
655
|
+
mediationAdapterClassName
|
656
|
+
)
|
657
|
+
put("responseInfoAdapterResponses", adapterResponses)
|
602
658
|
}
|
659
|
+
|
660
|
+
|
603
661
|
cWebView!!.loadUrl(
|
604
662
|
"javascript:cordova.fireDocumentEvent('on.interstitial.failed.load', ${errorData});"
|
605
663
|
)
|
@@ -623,7 +681,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
623
681
|
return true
|
624
682
|
} else if (action == "loadRewardedAd") {
|
625
683
|
val options = args.getJSONObject(0)
|
626
|
-
if(mActivity != null) {
|
684
|
+
if (mActivity != null) {
|
627
685
|
mActivity!!.runOnUiThread {
|
628
686
|
val adUnitId = options.optString("adUnitId")
|
629
687
|
val autoShow = options.optBoolean("autoShow")
|
@@ -637,11 +695,33 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
637
695
|
isRewardedLoad = false
|
638
696
|
|
639
697
|
val errorData = JSONObject().apply {
|
640
|
-
put("responseInfo", loadAdError.responseInfo.toString())
|
641
698
|
put("code", loadAdError.code)
|
642
699
|
put("message", loadAdError.message)
|
643
700
|
put("domain", loadAdError.domain)
|
644
701
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
702
|
+
|
703
|
+
|
704
|
+
val responseId =
|
705
|
+
loadAdError.responseInfo?.responseId.toString()
|
706
|
+
val responseExtras =
|
707
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
708
|
+
val loadedAdapterResponseInfo =
|
709
|
+
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
710
|
+
val mediationAdapterClassName =
|
711
|
+
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
712
|
+
val adapterResponses =
|
713
|
+
loadAdError.responseInfo?.adapterResponses.toString()
|
714
|
+
|
715
|
+
put("responseInfoId", responseId)
|
716
|
+
put("responseInfoExtras", responseExtras)
|
717
|
+
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
718
|
+
put(
|
719
|
+
"responseInfoMediationAdapterClassName",
|
720
|
+
mediationAdapterClassName
|
721
|
+
)
|
722
|
+
put("responseInfoAdapterResponses", adapterResponses)
|
723
|
+
|
724
|
+
|
645
725
|
}
|
646
726
|
|
647
727
|
cWebView!!.loadUrl(
|
@@ -717,7 +797,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
717
797
|
|
718
798
|
private val isRewardedAutoShow: Unit
|
719
799
|
get() {
|
720
|
-
if (mActivity != null){
|
800
|
+
if (mActivity != null) {
|
721
801
|
mActivity!!.runOnUiThread {
|
722
802
|
if (isRewardedLoad && rewardedAd != null) {
|
723
803
|
isAdSkip = 1
|
@@ -749,7 +829,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
749
829
|
}
|
750
830
|
return true
|
751
831
|
} else if (action == "showRewardedAd") {
|
752
|
-
if(mActivity != null && isRewardedLoad && rewardedAd != null) {
|
832
|
+
if (mActivity != null && isRewardedLoad && rewardedAd != null) {
|
753
833
|
mActivity!!.runOnUiThread {
|
754
834
|
isAdSkip = 1
|
755
835
|
rewardedAd!!.show(mActivity!!) { rewardItem: RewardItem ->
|
@@ -776,7 +856,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
776
856
|
return true
|
777
857
|
} else if (action == "loadRewardedInterstitialAd") {
|
778
858
|
val options = args.getJSONObject(0)
|
779
|
-
if(mActivity != null) {
|
859
|
+
if (mActivity != null) {
|
780
860
|
mActivity!!.runOnUiThread {
|
781
861
|
val adUnitId = options.optString("adUnitId")
|
782
862
|
val autoShow = options.optBoolean("autoShow")
|
@@ -850,12 +930,9 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
850
930
|
}
|
851
931
|
|
852
932
|
|
853
|
-
|
854
|
-
|
855
933
|
}
|
856
934
|
|
857
935
|
|
858
|
-
|
859
936
|
private val isRIntAutoShow: Unit
|
860
937
|
get() {
|
861
938
|
if (mActivity !== null) {
|
@@ -887,11 +964,30 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
887
964
|
rewardedInterstitialAd = null
|
888
965
|
isRewardedInterstitialLoad = false
|
889
966
|
val errorData = JSONObject().apply {
|
890
|
-
put("responseInfo", loadAdError.responseInfo.toString())
|
891
967
|
put("code", loadAdError.code)
|
892
968
|
put("message", loadAdError.message)
|
893
969
|
put("domain", loadAdError.domain)
|
894
970
|
put("cause", loadAdError.cause?.toString() ?: "null")
|
971
|
+
|
972
|
+
val responseId =
|
973
|
+
loadAdError.responseInfo?.responseId.toString()
|
974
|
+
val responseExtras =
|
975
|
+
loadAdError.responseInfo?.responseExtras.toString()
|
976
|
+
val loadedAdapterResponseInfo =
|
977
|
+
loadAdError.responseInfo?.loadedAdapterResponseInfo.toString()
|
978
|
+
val mediationAdapterClassName =
|
979
|
+
loadAdError.responseInfo?.mediationAdapterClassName.toString()
|
980
|
+
val adapterResponses =
|
981
|
+
loadAdError.responseInfo?.adapterResponses.toString()
|
982
|
+
|
983
|
+
put("responseInfoId", responseId)
|
984
|
+
put("responseInfoExtras", responseExtras)
|
985
|
+
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
986
|
+
put(
|
987
|
+
"responseInfoMediationAdapterClassName",
|
988
|
+
mediationAdapterClassName
|
989
|
+
)
|
990
|
+
put("responseInfoAdapterResponses", adapterResponses)
|
895
991
|
}
|
896
992
|
cWebView!!.loadUrl(
|
897
993
|
"javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load', ${errorData});"
|
@@ -906,7 +1002,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
906
1002
|
}
|
907
1003
|
return true
|
908
1004
|
} else if (action == "showRewardedInterstitialAd") {
|
909
|
-
if(mActivity != null) {
|
1005
|
+
if (mActivity != null) {
|
910
1006
|
mActivity!!.runOnUiThread {
|
911
1007
|
if (isRewardedInterstitialLoad && rewardedInterstitialAd != null) {
|
912
1008
|
isAdSkip = 1
|
@@ -934,7 +1030,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
934
1030
|
}
|
935
1031
|
return true
|
936
1032
|
} else if (action == "showPrivacyOptionsForm") {
|
937
|
-
if(mActivity != null) {
|
1033
|
+
if (mActivity != null) {
|
938
1034
|
mActivity!!.runOnUiThread {
|
939
1035
|
try {
|
940
1036
|
val params: ConsentRequestParameters
|
@@ -999,7 +1095,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
999
1095
|
}
|
1000
1096
|
return true
|
1001
1097
|
} else if (action == "consentReset") {
|
1002
|
-
if(mActivity != null) {
|
1098
|
+
if (mActivity != null) {
|
1003
1099
|
mActivity!!.runOnUiThread {
|
1004
1100
|
try {
|
1005
1101
|
consentInformation!!.reset()
|
@@ -1010,7 +1106,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1010
1106
|
}
|
1011
1107
|
return true
|
1012
1108
|
} else if (action == "getIabTfc") {
|
1013
|
-
if(mActivity != null) {
|
1109
|
+
if (mActivity != null) {
|
1014
1110
|
mActivity!!.runOnUiThread {
|
1015
1111
|
val gdprApplies = mPreferences!!.getInt("IABTCF_gdprApplies", 0)
|
1016
1112
|
val purposeConsents = mPreferences!!.getString("IABTCF_PurposeConsents", "")
|
@@ -1038,7 +1134,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1038
1134
|
}
|
1039
1135
|
return true
|
1040
1136
|
} else if (action == "loadBannerAd") {
|
1041
|
-
if(mActivity != null) {
|
1137
|
+
if (mActivity != null) {
|
1042
1138
|
val options = args.getJSONObject(0)
|
1043
1139
|
mActivity!!.runOnUiThread {
|
1044
1140
|
val adUnitId = options.optString("adUnitId")
|
@@ -1064,7 +1160,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1064
1160
|
}
|
1065
1161
|
return true
|
1066
1162
|
} else if (action == "showBannerAd") {
|
1067
|
-
if(mActivity != null) {
|
1163
|
+
if (mActivity != null) {
|
1068
1164
|
mActivity!!.runOnUiThread {
|
1069
1165
|
if (isBannerPause == 0) {
|
1070
1166
|
isShowBannerAds
|
@@ -1072,12 +1168,13 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1072
1168
|
try {
|
1073
1169
|
bannerView!!.visibility = View.VISIBLE
|
1074
1170
|
bannerView!!.resume()
|
1075
|
-
// bannerOverlappingToZero()
|
1076
1171
|
|
1077
1172
|
if (isOverlapping) {
|
1078
|
-
|
1173
|
+
bannerOverlapping()
|
1079
1174
|
}
|
1080
1175
|
|
1176
|
+
bannerViewLayout!!.requestFocus();
|
1177
|
+
|
1081
1178
|
|
1082
1179
|
} catch (e: Exception) {
|
1083
1180
|
callbackContext.error(e.toString())
|
@@ -1088,7 +1185,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1088
1185
|
return true
|
1089
1186
|
} else if (action == "styleBannerAd") {
|
1090
1187
|
val options = args.getJSONObject(0)
|
1091
|
-
if(mActivity != null) {
|
1188
|
+
if (mActivity != null) {
|
1092
1189
|
mActivity!!.runOnUiThread {
|
1093
1190
|
val isOverlapping = options.optBoolean("isOverlapping")
|
1094
1191
|
val overlappingHeight = options.optInt("overlappingHeight")
|
@@ -1107,7 +1204,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1107
1204
|
return true
|
1108
1205
|
} else if (action == "collapsibleBannerAd") {
|
1109
1206
|
val options = args.getJSONObject(0)
|
1110
|
-
if(mActivity != null) {
|
1207
|
+
if (mActivity != null) {
|
1111
1208
|
mActivity!!.runOnUiThread {
|
1112
1209
|
val enableCollapsible = options.optBoolean("enabledBannerCollapsible")
|
1113
1210
|
val collapsible = options.optString("collapsiblePosition")
|
@@ -1121,7 +1218,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1121
1218
|
}
|
1122
1219
|
return true
|
1123
1220
|
} else if (action == "hideBannerAd") {
|
1124
|
-
if(mActivity != null) {
|
1221
|
+
if (mActivity != null) {
|
1125
1222
|
mActivity!!.runOnUiThread {
|
1126
1223
|
if (isBannerShow) {
|
1127
1224
|
try {
|
@@ -1138,7 +1235,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1138
1235
|
}
|
1139
1236
|
return true
|
1140
1237
|
} else if (action == "removeBannerAd") {
|
1141
|
-
if(mActivity != null) {
|
1238
|
+
if (mActivity != null) {
|
1142
1239
|
mActivity!!.runOnUiThread {
|
1143
1240
|
try {
|
1144
1241
|
if (bannerViewLayout != null && bannerView != null) {
|
@@ -1158,11 +1255,70 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1158
1255
|
}
|
1159
1256
|
}
|
1160
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
|
1161
1284
|
}
|
1162
1285
|
return false
|
1163
1286
|
}
|
1164
1287
|
|
1165
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
|
+
|
1166
1322
|
|
1167
1323
|
private fun loadBannerAd(adUnitId: String, position: String, size: String) {
|
1168
1324
|
try {
|
@@ -1258,6 +1414,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1258
1414
|
if (lock) {
|
1259
1415
|
bannerViewLayout!!.addView(bannerView)
|
1260
1416
|
bannerViewLayout!!.bringToFront()
|
1417
|
+
bannerViewLayout!!.requestFocus();
|
1261
1418
|
lock = false
|
1262
1419
|
}
|
1263
1420
|
isBannerPause = 0
|
@@ -1282,6 +1439,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1282
1439
|
if (lock) {
|
1283
1440
|
bannerViewLayout!!.addView(bannerView)
|
1284
1441
|
bannerViewLayout!!.bringToFront()
|
1442
|
+
bannerViewLayout!!.requestFocus();
|
1285
1443
|
lock = false
|
1286
1444
|
}
|
1287
1445
|
isBannerShow = true
|
@@ -1305,11 +1463,25 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1305
1463
|
|
1306
1464
|
override fun onAdFailedToLoad(adError: LoadAdError) {
|
1307
1465
|
val errorData = JSONObject().apply {
|
1308
|
-
put("responseInfo", adError.responseInfo.toString())
|
1309
1466
|
put("code", adError.code)
|
1310
1467
|
put("message", adError.message)
|
1311
1468
|
put("domain", adError.domain)
|
1312
1469
|
put("cause", adError.cause?.toString() ?: "null")
|
1470
|
+
|
1471
|
+
val responseId = adError.responseInfo?.responseId.toString()
|
1472
|
+
val responseExtras = adError.responseInfo?.responseExtras.toString()
|
1473
|
+
val loadedAdapterResponseInfo =
|
1474
|
+
adError.responseInfo?.loadedAdapterResponseInfo.toString()
|
1475
|
+
val mediationAdapterClassName =
|
1476
|
+
adError.responseInfo?.mediationAdapterClassName.toString()
|
1477
|
+
val adapterResponses =
|
1478
|
+
adError.responseInfo?.adapterResponses.toString()
|
1479
|
+
|
1480
|
+
put("responseInfoId", responseId)
|
1481
|
+
put("responseInfoExtras", responseExtras)
|
1482
|
+
put("responseInfoAdapter", loadedAdapterResponseInfo)
|
1483
|
+
put("responseInfoMediationAdapterClassName", mediationAdapterClassName)
|
1484
|
+
put("responseInfoAdapterResponses", adapterResponses)
|
1313
1485
|
}
|
1314
1486
|
|
1315
1487
|
cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load', ${errorData});")
|
@@ -2103,3 +2275,5 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2103
2275
|
}
|
2104
2276
|
|
2105
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
|
};
|