emi-indo-cordova-plugin-admob 1.6.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 +24 -11
- package/capacitor-hook-admob-ids.js +19 -17
- 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 +174 -0
- package/package.json +5 -3
- package/plugin.xml +4 -4
- package/src/android/emiAdmobPlugin.kt +51 -9
package/README.md
CHANGED
@@ -1,28 +1,45 @@
|
|
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
|
+
|
14
|
+
> [!NOTE]
|
15
|
+
> - To maintain this plugin in the long run,
|
16
|
+
> - for (regular maintenance),
|
17
|
+
> - just give me a cup of coffee.
|
18
|
+
|
19
|
+
## 💰Sponsor this project
|
20
|
+
[](https://paypal.me/emiindo)
|
21
|
+
[](https://ko-fi.com/F1F16NI8H)
|
22
|
+
## [Check all release notes:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/)
|
23
|
+
|
10
24
|
|
11
25
|
### Mobile Ads SDK (Android: 23.6.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
|
12
26
|
### User Messaging Platform (UMP Android: 3.1.0) [Release Notes:](https://developers.google.com/admob/android/privacy/release-notes)
|
13
27
|
|
14
|
-
### Mobile Ads SDK (IOS: 11.
|
28
|
+
### Mobile Ads SDK (IOS: 11.13.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
|
15
29
|
|
16
30
|
### User Messaging Platform (UMP IOS: 2.7.0) [Release Notes:](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download)
|
17
|
-
### IAB Europe Transparency & Consent Framework (
|
31
|
+
### IAB Europe Transparency & Consent Framework (CMP: 2.2.0)
|
18
32
|
|
19
|
-
## New example
|
20
|
-
- https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/tree/main/example/www
|
21
33
|
|
22
34
|
|
23
35
|
## Documentation Capacitor example
|
24
36
|
- [Documentation Capacitor example: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/29)
|
25
37
|
|
38
|
+
### This is not a dependency, it's a separate plugin but highly recommended.
|
39
|
+
https://github.com/EMI-INDO/emi-indo-cordova-plugin-fanalytics
|
40
|
+
|
41
|
+
## New example
|
42
|
+
- https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/tree/main/example/www
|
26
43
|
|
27
44
|
|
28
45
|
## Minimum Cordova Engines
|
@@ -31,6 +48,7 @@
|
|
31
48
|
|
32
49
|
|
33
50
|
## IOS Ad Support IOS 18 *
|
51
|
+
- Fix error build IOS: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/42
|
34
52
|
- Mobile Ads SDK (IOS: 11.12.0)
|
35
53
|
- emi-indo-cordova-plugin-admob@1.6.3 or higher requires cocoapods 1.16.2 or higher
|
36
54
|
> [!WARNING]
|
@@ -100,11 +118,6 @@ https://developers.google.com/admob/ios/quick-start
|
|
100
118
|
|
101
119
|
|
102
120
|
|
103
|
-
## 💰Sponsor this project
|
104
|
-
[](https://paypal.me/emiindo)
|
105
|
-
[](https://ko-fi.com/F1F16NI8H)
|
106
|
-
## [Check all release notes:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/)
|
107
|
-
|
108
121
|
|
109
122
|
|
110
123
|
## Features
|
@@ -6,14 +6,12 @@ const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
6
6
|
const androidPlatformPath = path.join(process.cwd(), 'android');
|
7
7
|
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
8
8
|
const pluginPath = path.join(process.cwd(), 'node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
9
|
-
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
10
|
-
|
9
|
+
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
11
10
|
|
12
11
|
function fileExists(filePath) {
|
13
12
|
return fs.existsSync(filePath);
|
14
13
|
}
|
15
14
|
|
16
|
-
|
17
15
|
function getAdMobConfig() {
|
18
16
|
if (!fileExists(configPath)) {
|
19
17
|
throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
|
@@ -29,10 +27,10 @@ function getAdMobConfig() {
|
|
29
27
|
return {
|
30
28
|
APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
|
31
29
|
APP_ID_IOS: admobConfig.APP_ID_IOS,
|
30
|
+
USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
|
32
31
|
};
|
33
32
|
}
|
34
33
|
|
35
|
-
|
36
34
|
function updatePluginXml(admobConfig) {
|
37
35
|
if (!fileExists(pluginPath)) {
|
38
36
|
console.error('plugin.xml not found. Ensure the plugin is installed.');
|
@@ -45,11 +43,22 @@ function updatePluginXml(admobConfig) {
|
|
45
43
|
.replace(/<preference name="APP_ID_ANDROID" default=".*?" \/>/, `<preference name="APP_ID_ANDROID" default="${admobConfig.APP_ID_ANDROID}" />`)
|
46
44
|
.replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
|
47
45
|
|
46
|
+
if (admobConfig.USE_LITE_ADS) {
|
47
|
+
pluginContent = pluginContent.replace(
|
48
|
+
/<framework src="com.google.android.gms:play-services-ads:.*?" \/>/,
|
49
|
+
`<framework src="com.google.android.gms:play-services-ads-lite:$PLAY_SERVICES_VERSION" />`
|
50
|
+
);
|
51
|
+
} else {
|
52
|
+
pluginContent = pluginContent.replace(
|
53
|
+
/<framework src="com.google.android.gms:play-services-ads-lite:.*?" \/>/,
|
54
|
+
`<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />`
|
55
|
+
);
|
56
|
+
}
|
57
|
+
|
48
58
|
fs.writeFileSync(pluginPath, pluginContent, 'utf8');
|
49
|
-
console.log('AdMob IDs successfully updated in plugin.xml');
|
59
|
+
console.log('AdMob IDs and framework dependency successfully updated in plugin.xml');
|
50
60
|
}
|
51
61
|
|
52
|
-
|
53
62
|
function updateInfoPlist(admobConfig) {
|
54
63
|
if (!fileExists(infoPlistPath)) {
|
55
64
|
console.error('Info.plist not found. Ensure you have built the iOS project.');
|
@@ -59,13 +68,8 @@ function updateInfoPlist(admobConfig) {
|
|
59
68
|
const plistContent = fs.readFileSync(infoPlistPath, 'utf8');
|
60
69
|
const plistData = plist.parse(plistContent);
|
61
70
|
|
62
|
-
|
63
71
|
plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
|
64
|
-
|
65
|
-
|
66
72
|
plistData.NSUserTrackingUsageDescription = 'This identifier will be used to deliver personalized ads to you.';
|
67
|
-
|
68
|
-
|
69
73
|
plistData.GADDelayAppMeasurementInit = true;
|
70
74
|
|
71
75
|
// https://developers.google.com/admob/ios/quick-start
|
@@ -114,15 +118,12 @@ function updateInfoPlist(admobConfig) {
|
|
114
118
|
{ SKAdNetworkIdentifier: '3qcr597p9d.skadnetwork' }, // Zucks
|
115
119
|
];
|
116
120
|
|
117
|
-
|
118
121
|
const updatedPlistContent = plist.build(plistData);
|
119
122
|
fs.writeFileSync(infoPlistPath, updatedPlistContent, 'utf8');
|
120
123
|
console.log('AdMob IDs and additional configurations successfully updated in Info.plist');
|
121
124
|
}
|
122
125
|
|
123
|
-
|
124
126
|
try {
|
125
|
-
|
126
127
|
if (!fileExists(configPath)) {
|
127
128
|
throw new Error('capacitor.config.json not found. Skipping setup.');
|
128
129
|
}
|
@@ -131,18 +132,19 @@ try {
|
|
131
132
|
throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
|
132
133
|
}
|
133
134
|
|
134
|
-
|
135
135
|
const admobConfig = getAdMobConfig();
|
136
136
|
|
137
|
-
|
138
137
|
if (fileExists(androidPlatformPath)) {
|
139
138
|
updatePluginXml(admobConfig);
|
140
139
|
}
|
141
140
|
|
142
|
-
|
143
141
|
if (fileExists(iosPlatformPath)) {
|
144
142
|
updateInfoPlist(admobConfig);
|
145
143
|
}
|
146
144
|
} catch (error) {
|
147
145
|
console.error(error.message);
|
148
146
|
}
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
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
|
|
@@ -0,0 +1,174 @@
|
|
1
|
+
|
2
|
+
// NOTE
|
3
|
+
// This is not a dependency, it's a separate plugin but highly recommended.
|
4
|
+
// https://github.com/EMI-INDO/emi-indo-cordova-plugin-fanalytics
|
5
|
+
|
6
|
+
// Just one example, for example Interstitial ads, the others just adjust it
|
7
|
+
|
8
|
+
// https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/www/js/interstitialAd.js
|
9
|
+
|
10
|
+
let isInterstitialLoadAd = false;
|
11
|
+
|
12
|
+
function loadInterstitialAd() {
|
13
|
+
|
14
|
+
if (typeof cordova !== 'undefined') {
|
15
|
+
|
16
|
+
cordova.plugins.emiAdmobPlugin.loadInterstitialAd({ adUnitId: Interstitial_ID, autoShow: false });
|
17
|
+
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
function showInterstitialAd() {
|
24
|
+
|
25
|
+
if (typeof cordova !== 'undefined') {
|
26
|
+
|
27
|
+
if (isInterstitialLoadAd) {
|
28
|
+
cordova.plugins.emiAdmobPlugin.showInterstitialAd();
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
/*
|
35
|
+
|
36
|
+
on.interstitial.loaded
|
37
|
+
on.interstitial.failed.load
|
38
|
+
on.interstitial.click
|
39
|
+
on.interstitial.dismissed
|
40
|
+
on.interstitial.failed.show
|
41
|
+
on.interstitial.impression
|
42
|
+
on.interstitial.show
|
43
|
+
|
44
|
+
// New event plugin v1.5.5 or higher
|
45
|
+
|
46
|
+
on.interstitial.revenue
|
47
|
+
on.interstitialAd.responseInfo
|
48
|
+
|
49
|
+
*/
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
let interstitialErrMsg = "";
|
55
|
+
|
56
|
+
const adEventData = {
|
57
|
+
// NOTE: no spaces, underline is recommended _
|
58
|
+
on_interstitial_loaded: "on_interstitial_loaded",
|
59
|
+
on_interstitial_failed_load: interstitialErrMsg,
|
60
|
+
on_interstitial_click: "on_interstitial_click",
|
61
|
+
on_interstitial_dismissed: "on_interstitial_dismissed",
|
62
|
+
on_interstitial_failed_show: "on_interstitial_failed_show",
|
63
|
+
on_interstitial_impression: "on_interstitial_impression",
|
64
|
+
on_interstitial_show: "on_interstitial_show",
|
65
|
+
on_interstitial_revenue: "on_interstitial_revenue"
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
// EVENT For example
|
71
|
+
|
72
|
+
document.addEventListener('on.interstitial.loaded', () => {
|
73
|
+
isInterstitialLoadAd = true;
|
74
|
+
console.log("on interstitial Ad loaded");
|
75
|
+
|
76
|
+
if (typeof cordova !== 'undefined') {
|
77
|
+
|
78
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_loaded", params: adEventData.on_interstitial_loaded });
|
79
|
+
|
80
|
+
}
|
81
|
+
|
82
|
+
});
|
83
|
+
|
84
|
+
|
85
|
+
// all events that contain the keyword dismissed there is a block to load the ad after it is closed by the user.
|
86
|
+
document.addEventListener('on.interstitial.dismissed', () => {
|
87
|
+
isInterstitialLoadAd = false;
|
88
|
+
console.log("on interstitial Ad dismissed");
|
89
|
+
console.log("you can load ads automatically after the ads are closed by users");
|
90
|
+
|
91
|
+
loadInterstitialAd();
|
92
|
+
|
93
|
+
if (typeof cordova !== 'undefined') {
|
94
|
+
|
95
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_dismissed", params: adEventData.on_interstitial_dismissed });
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
});
|
100
|
+
|
101
|
+
|
102
|
+
document.addEventListener('on.interstitial.failed.load', (error) => {
|
103
|
+
isInterstitialLoadAd = false;
|
104
|
+
console.log("on.interstitial.failed.load" + JSON.stringify(error));
|
105
|
+
|
106
|
+
/*
|
107
|
+
error.code
|
108
|
+
error.message
|
109
|
+
error.domain
|
110
|
+
error.responseInfoId
|
111
|
+
error.responseInfoExtras
|
112
|
+
error.responseInfoAdapter
|
113
|
+
error.responseInfoMediationAdapterClassName
|
114
|
+
error.responseInfoAdapterResponses
|
115
|
+
*/
|
116
|
+
|
117
|
+
interstitialErrMsg = error.message;
|
118
|
+
|
119
|
+
if (typeof cordova !== 'undefined') {
|
120
|
+
|
121
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_failed_load", params: adEventData.on_interstitial_failed_load });
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
});
|
127
|
+
|
128
|
+
|
129
|
+
document.addEventListener('on.interstitial.failed.show', (error) => {
|
130
|
+
isInterstitialLoadAd = false;
|
131
|
+
console.log("on.interstitial.failed.show" + JSON.stringify(error));
|
132
|
+
|
133
|
+
|
134
|
+
if (typeof cordova !== 'undefined') {
|
135
|
+
|
136
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_failed_show", params: adEventData.on_interstitial_failed_show });
|
137
|
+
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
});
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
/*
|
148
|
+
https://support.google.com/admob/answer/11322405
|
149
|
+
|
150
|
+
Turn on the setting for impression-level ad revenue in your AdMob account:
|
151
|
+
Sign in to your AdMob account at https://apps.admob.com.
|
152
|
+
Click Settings in the sidebar.
|
153
|
+
Click the Account tab.
|
154
|
+
In the Account controls section, click the Impression-level ad revenue toggle to turn on this setting.
|
155
|
+
*/
|
156
|
+
|
157
|
+
document.addEventListener('on.interstitial.revenue', (data) => {
|
158
|
+
|
159
|
+
let adRevenuePaid = {
|
160
|
+
value: data.value,
|
161
|
+
currencyCode: data.currencyCode,
|
162
|
+
precision: data.precision,
|
163
|
+
adUnitId: data.adUnitId
|
164
|
+
}
|
165
|
+
|
166
|
+
if (typeof cordova !== 'undefined') {
|
167
|
+
|
168
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.setAdMobRevenuePaid({ data: adRevenuePaid });
|
169
|
+
|
170
|
+
cordova.plugins.EmiFirebaseAnalyticsPlugin.logEvent({ name: "on_interstitial_revenue", params: adEventData.on_interstitial_revenue });
|
171
|
+
|
172
|
+
}
|
173
|
+
|
174
|
+
});
|
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
|
|
@@ -300,7 +300,7 @@
|
|
300
300
|
<pods use-frameworks="true">
|
301
301
|
<!--minimum macOS 14.4 > Xcode 15.3 -->
|
302
302
|
<pod name="GoogleUserMessagingPlatform" spec="~> 2.7.0" />
|
303
|
-
<pod name="Google-Mobile-Ads-SDK" spec="~> 11.
|
303
|
+
<pod name="Google-Mobile-Ads-SDK" spec="~> 11.13.0" />
|
304
304
|
|
305
305
|
</pods>
|
306
306
|
</podspec>
|
@@ -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
|
}
|