emi-indo-cordova-plugin-admob 1.7.9 → 1.8.9
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 -2
- package/example/capacitor.config.json +2 -1
- package/example/package.json +1 -1
- package/example/www/js/bannerAd.js +30 -6
- package/example/www/js/deviceready.js +1 -1
- package/example/www/js/optionalFirebaseAnalytics.js +5 -5
- package/package.json +5 -3
- package/plugin.xml +3 -3
- package/src/android/emiAdmobPlugin.kt +51 -9
package/README.md
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
|
2
2
|
|
3
3
|
### emi-indo-cordova-plugin-admob
|
4
|
-
Cordova Plugin Admob Android and IOS
|
5
|
-
## Support
|
4
|
+
Cordova/Quasar/Capacitor Plugin Admob Android and IOS
|
5
|
+
## Support Request Ad Builder
|
6
6
|
- AdMob
|
7
7
|
- AdManager
|
8
8
|
- AdSense New [example ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/adSense.js)
|
9
9
|
|
10
|
+
## Support framework
|
11
|
+
- Quasar: https://github.com/quasarframework/quasar/discussions/17706
|
12
|
+
- Capacitor: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/29
|
13
|
+
|
10
14
|
> [!NOTE]
|
11
15
|
> - To maintain this plugin in the long run,
|
12
16
|
> - for (regular maintenance),
|
@@ -44,6 +48,7 @@ https://github.com/EMI-INDO/emi-indo-cordova-plugin-fanalytics
|
|
44
48
|
|
45
49
|
|
46
50
|
## IOS Ad Support IOS 18 *
|
51
|
+
- Fix error build IOS: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/42
|
47
52
|
- Mobile Ads SDK (IOS: 11.12.0)
|
48
53
|
- emi-indo-cordova-plugin-admob@1.6.3 or higher requires cocoapods 1.16.2 or higher
|
49
54
|
> [!WARNING]
|
package/example/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// ccordova.plugins.emiAdmobPlugin.styleBannerAd({isOverlapping: true, overlappingHeight:
|
1
|
+
// ccordova.plugins.emiAdmobPlugin.styleBannerAd({isOverlapping: true, overlappingHeight: 0, padding: 0, margins: 0 }); // ( only android)
|
2
2
|
//cordova.plugins.emiAdmobPlugin.loadBannerAd({config});
|
3
3
|
//cordova.plugins.emiAdmobPlugin.showBannerAd(); // default
|
4
4
|
//cordova.plugins.emiAdmobPlugin.hideBannerAd(); // default
|
@@ -14,9 +14,9 @@ function loadBanner() {
|
|
14
14
|
|
15
15
|
cordova.plugins.emiAdmobPlugin.styleBannerAd({
|
16
16
|
isOverlapping: true,
|
17
|
-
overlappingHeight:
|
18
|
-
padding: 0,
|
19
|
-
margins: 0
|
17
|
+
overlappingHeight: 0, // default 0 (Automatic)
|
18
|
+
padding: 0, // default 0
|
19
|
+
margins: 0 // default 0 (Automatic)
|
20
20
|
});
|
21
21
|
|
22
22
|
}
|
@@ -24,7 +24,7 @@ function loadBanner() {
|
|
24
24
|
|
25
25
|
cordova.plugins.emiAdmobPlugin.loadBannerAd({
|
26
26
|
adUnitId: Banner_ID, //Banner_ID,
|
27
|
-
position: "bottom-center",
|
27
|
+
position: "bottom-center", // "Recommended: bottom-center"
|
28
28
|
size: "banner", // autoResize: true (only responsive_adaptive)
|
29
29
|
collapsible: "bottom", // position: top | bottom (disable, empty string)
|
30
30
|
autoResize: true, // default false
|
@@ -114,9 +114,33 @@ on.banner.hide
|
|
114
114
|
|
115
115
|
// EVENT For example
|
116
116
|
|
117
|
+
|
118
|
+
// (Optional)
|
119
|
+
// This is only triggered when cordova.plugins.emiAdmobPlugin.styleBannerAd
|
120
|
+
document.addEventListener('on.style.banner.ad', (data) => {
|
121
|
+
console.log("on.style.banner.ad: " + JSON.stringify(data));
|
122
|
+
/*
|
123
|
+
const navBarHeight = data.navBarHeight;
|
124
|
+
const screenHeight = data.screenHeight;
|
125
|
+
const usableHeight = data.usableHeight;
|
126
|
+
const isOverlapping = data.isOverlapping;
|
127
|
+
const overlappingHeight = data.overlappingHeight;
|
128
|
+
const paddingInPx = data.paddingInPx;
|
129
|
+
const marginsInPx = data.marginsInPx;
|
130
|
+
*/
|
131
|
+
|
132
|
+
// You can load banner ads here, or manipulate variables, even rearrange cordova.plugins.emiAdmobPlugin.styleBannerAd to your liking.
|
133
|
+
|
134
|
+
|
135
|
+
});
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
117
141
|
document.addEventListener('on.banner.load', (arg) => {
|
118
142
|
let bannerAdHeight=arg.height;
|
119
|
-
console.log("on banner load");
|
143
|
+
console.log("on banner load", bannerAdHeight);
|
120
144
|
});
|
121
145
|
|
122
146
|
|
@@ -75,7 +75,7 @@ document.addEventListener('on.interstitial.loaded', () => {
|
|
75
75
|
|
76
76
|
if (typeof cordova !== 'undefined') {
|
77
77
|
|
78
|
-
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "
|
78
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_loaded", params: adEventData.on_interstitial_loaded });
|
79
79
|
|
80
80
|
}
|
81
81
|
|
@@ -92,7 +92,7 @@ document.addEventListener('on.interstitial.dismissed', () => {
|
|
92
92
|
|
93
93
|
if (typeof cordova !== 'undefined') {
|
94
94
|
|
95
|
-
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "
|
95
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_dismissed", params: adEventData.on_interstitial_dismissed });
|
96
96
|
|
97
97
|
}
|
98
98
|
|
@@ -118,7 +118,7 @@ document.addEventListener('on.interstitial.failed.load', (error) => {
|
|
118
118
|
|
119
119
|
if (typeof cordova !== 'undefined') {
|
120
120
|
|
121
|
-
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "
|
121
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_failed_load", params: adEventData.on_interstitial_failed_load });
|
122
122
|
|
123
123
|
}
|
124
124
|
|
@@ -133,7 +133,7 @@ document.addEventListener('on.interstitial.failed.show', (error) => {
|
|
133
133
|
|
134
134
|
if (typeof cordova !== 'undefined') {
|
135
135
|
|
136
|
-
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "
|
136
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_failed_show", params: adEventData.on_interstitial_failed_show });
|
137
137
|
|
138
138
|
}
|
139
139
|
|
@@ -167,7 +167,7 @@ document.addEventListener('on.interstitial.revenue', (data) => {
|
|
167
167
|
|
168
168
|
cordova.plugins.EmiFirebaseAnalyticsPlugin.setAdMobRevenuePaid({ data: adRevenuePaid });
|
169
169
|
|
170
|
-
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "
|
170
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_revenue", params: adEventData.on_interstitial_revenue });
|
171
171
|
|
172
172
|
}
|
173
173
|
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "emi-indo-cordova-plugin-admob",
|
3
|
-
"version": "1.
|
4
|
-
"description": "Cordova Plugin Admob Android IOS
|
3
|
+
"version": "1.8.9",
|
4
|
+
"description": "Cordova/Quasar/Capacitor Plugin Admob Android IOS",
|
5
5
|
"cordova": {
|
6
6
|
"id": "emi-indo-cordova-plugin-admob",
|
7
7
|
"platforms": [
|
@@ -27,7 +27,9 @@
|
|
27
27
|
"capacitor-ios",
|
28
28
|
"adsense",
|
29
29
|
"webview",
|
30
|
-
"admanager"
|
30
|
+
"admanager",
|
31
|
+
"quasar-framework",
|
32
|
+
"quasar"
|
31
33
|
],
|
32
34
|
"author": "EMI INDO",
|
33
35
|
"email": "cordova.c3addon@gmail.com",
|
package/plugin.xml
CHANGED
@@ -1,9 +1,9 @@
|
|
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.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="1.8.9">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
|
-
<description>Cordova Plugin Admob Android IOS</description>
|
6
|
+
<description>Cordova/Quasar/Capacitor Plugin Admob Android IOS</description>
|
7
7
|
<author>EMI INDO</author>
|
8
8
|
<license>ISC</license>
|
9
9
|
|
@@ -93,7 +93,7 @@
|
|
93
93
|
|
94
94
|
<config-file parent="/*" target="config.xml">
|
95
95
|
<!--minimum deployment-target: 12.2 -->
|
96
|
-
<preference name="deployment-target" value="12.
|
96
|
+
<preference name="deployment-target" value="12.3" />
|
97
97
|
<preference name="SwiftVersion" value="5.10" />
|
98
98
|
</config-file>
|
99
99
|
|
@@ -5,6 +5,7 @@ import android.content.Context
|
|
5
5
|
import android.content.Intent
|
6
6
|
import android.content.SharedPreferences
|
7
7
|
import android.content.res.Configuration
|
8
|
+
import android.graphics.Point
|
8
9
|
import android.os.Build
|
9
10
|
import android.os.Bundle
|
10
11
|
import android.provider.Settings
|
@@ -1197,18 +1198,59 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1197
1198
|
val options = args.getJSONObject(0)
|
1198
1199
|
if (mActivity != null) {
|
1199
1200
|
mActivity!!.runOnUiThread {
|
1200
|
-
val
|
1201
|
-
val
|
1202
|
-
|
1203
|
-
|
1201
|
+
val screenHeight: Int
|
1202
|
+
val usableHeight: Int
|
1203
|
+
|
1204
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
1205
|
+
val windowMetrics = cordova.activity.windowManager.currentWindowMetrics
|
1206
|
+
val insets = windowMetrics.windowInsets.getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars())
|
1207
|
+
screenHeight = windowMetrics.bounds.height()
|
1208
|
+
usableHeight = screenHeight - insets.bottom
|
1209
|
+
} else {
|
1210
|
+
val display = cordova.activity.windowManager.defaultDisplay
|
1211
|
+
val size = Point()
|
1212
|
+
val realSize = Point()
|
1213
|
+
display.getSize(size)
|
1214
|
+
display.getRealSize(realSize)
|
1215
|
+
|
1216
|
+
usableHeight = size.y
|
1217
|
+
screenHeight = realSize.y
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
val navBarHeight = maxOf(0, screenHeight - usableHeight)
|
1221
|
+
|
1222
|
+
val isOverlapping = options.optBoolean("isOverlapping", false)
|
1223
|
+
val overlappingHeight = options.optInt("overlappingHeight", navBarHeight)
|
1224
|
+
val paddingPx = options.optInt("padding", 0)
|
1225
|
+
val marginsPx = options.optInt("margins", navBarHeight)
|
1226
|
+
|
1227
|
+
val result = JSONObject()
|
1204
1228
|
try {
|
1229
|
+
// Make sure to only set variables if they have the correct values
|
1205
1230
|
this.isOverlapping = isOverlapping
|
1206
|
-
this.overlappingHeight = overlappingHeight
|
1231
|
+
this.overlappingHeight = if (overlappingHeight > 0) overlappingHeight else navBarHeight
|
1207
1232
|
this.paddingInPx = paddingPx
|
1208
|
-
this.marginsInPx = marginsPx
|
1233
|
+
this.marginsInPx = if (marginsPx > 0) marginsPx else navBarHeight
|
1234
|
+
|
1235
|
+
// Add more useful data to the result
|
1236
|
+
result.put("navBarHeight", navBarHeight)
|
1237
|
+
result.put("screenHeight", screenHeight)
|
1238
|
+
result.put("usableHeight", usableHeight)
|
1239
|
+
result.put("isOverlapping", isOverlapping)
|
1240
|
+
result.put("overlappingHeight", this.overlappingHeight)
|
1241
|
+
result.put("paddingInPx", paddingPx)
|
1242
|
+
result.put("marginsInPx", this.marginsInPx)
|
1243
|
+
|
1244
|
+
cWebView?.let {
|
1245
|
+
it.loadUrl("javascript:cordova.fireDocumentEvent('on.style.banner.ad', ${result});")
|
1246
|
+
} ?: run {
|
1247
|
+
callbackContext.error("Error: cWebView is null.")
|
1248
|
+
}
|
1249
|
+
|
1209
1250
|
} catch (e: Exception) {
|
1210
|
-
callbackContext.error(e.
|
1251
|
+
callbackContext.error("Error in styleBannerAd: ${e.message}")
|
1211
1252
|
}
|
1253
|
+
|
1212
1254
|
}
|
1213
1255
|
}
|
1214
1256
|
return true
|
@@ -1609,7 +1651,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1609
1651
|
if (bannerView != null && mActivity != null && cWebView != null) {
|
1610
1652
|
mActivity!!.runOnUiThread {
|
1611
1653
|
try {
|
1612
|
-
|
1654
|
+
// val bannerHeightInPx = bannerView!!.height
|
1613
1655
|
val displayMetrics = DisplayMetrics()
|
1614
1656
|
mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
|
1615
1657
|
val screenHeightInPx = displayMetrics.heightPixels
|
@@ -2006,7 +2048,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
2006
2048
|
}
|
2007
2049
|
return sb.toString().uppercase(Locale.getDefault())
|
2008
2050
|
} catch (ex: NoSuchAlgorithmException) {
|
2009
|
-
|
2051
|
+
ex.printStackTrace();
|
2010
2052
|
return null
|
2011
2053
|
}
|
2012
2054
|
}
|