emi-indo-cordova-plugin-admob 1.4.3 → 1.4.4
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 +431 -218
- package/example/banner_ads.html +15 -1
- package/example/wewrtr.html +0 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/emiAdmobPlugin.java +1 -1
- package/www/emiAdmobPlugin.js +15 -16
package/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
# emi-indo-cordova-plugin-admob
|
2
4
|
Cordova Plugin Admob Android and IOS
|
3
5
|
|
@@ -17,8 +19,43 @@
|
|
17
19
|
- Target iOS 11.0 or higher
|
18
20
|
https://developers.google.com/admob/ios/quick-start
|
19
21
|
|
22
|
+
<details>
|
23
|
+
<summary>Guaranteed income using this plugin #14</summary>
|
24
|
+
|
25
|
+
> __Note__
|
26
|
+
> - ## It's Not a fork, it's purely rewritten, clean of 3rd party code.
|
27
|
+
|
28
|
+
> __Note__
|
29
|
+
> - ### No Ad-Sharing
|
30
|
+
> - ### No Remote Control
|
31
|
+
> - ### I guarantee 100% revenue for you.
|
32
|
+
> - [Code source:](https://github.com/googleads/googleads-mobile-android-examples) - Admob:
|
33
|
+
> -
|
34
|
+
</details>
|
20
35
|
|
36
|
+
## 💰Sponsor this project
|
37
|
+
[](https://paypal.me/emiindo)
|
38
|
+
|
39
|
+
## [Check all release notes:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/)
|
21
40
|
|
41
|
+
## Features
|
42
|
+
<details>
|
43
|
+
<summary>Features #1</summary>
|
44
|
+
<ul>
|
45
|
+
<li> initialize</li>
|
46
|
+
<li> targeting</li>
|
47
|
+
<li> globalSettings</li>
|
48
|
+
<li> AppTrackingTransparency (ATT)</li>
|
49
|
+
<li> CMP SDK</li>
|
50
|
+
<li> UMP SDK</li>
|
51
|
+
<li> App Open Ads</li>
|
52
|
+
<li> Banner Ads</li>
|
53
|
+
<li> Interstitial Ads</li>
|
54
|
+
<li> Rewarded Ads</li>
|
55
|
+
<li> Mediation</li>
|
56
|
+
<li> impression-level-ad-revenue</li>
|
57
|
+
</ul>
|
58
|
+
</details>
|
22
59
|
|
23
60
|
## Installation
|
24
61
|
|
@@ -36,7 +73,7 @@ cordova plugin rm emi-indo-cordova-plugin-admob
|
|
36
73
|
|
37
74
|
|
38
75
|
|
39
|
-
## Import the Mobile Ads SDK
|
76
|
+
## Import the Mobile Ads SDK IOS
|
40
77
|
### Then from the command line run:
|
41
78
|
- cd platforms/ios
|
42
79
|
### Then from the command line run:
|
@@ -44,260 +81,456 @@ cordova plugin rm emi-indo-cordova-plugin-admob
|
|
44
81
|
|
45
82
|
|
46
83
|
|
47
|
-
|
48
|
-
|
49
|
-
- [AppTrackingTransparency (ATT) framework:](https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus)
|
50
|
-
- [Consent Management Platform API:](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#in-app-details)
|
84
|
+
## >>> Device Ready <<<
|
51
85
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
// Support Platform: Android or IOS
|
57
|
-
<script>
|
86
|
+
<details>
|
87
|
+
<summary>Methods: #2</summary>
|
88
|
+
<pre>
|
89
|
+
// Support Platform: Android | IOS
|
58
90
|
cordova.plugins.emiAdmobPlugin.globalSettings([config_globalSettings]);
|
59
91
|
cordova.plugins.emiAdmobPlugin.targeting([config_Targeting]);
|
60
92
|
cordova.plugins.emiAdmobPlugin.initialize();
|
61
|
-
|
62
|
-
/*
|
63
|
-
cordova.plugins.emiAdmobPlugin.requestIDFA(); // UMP SDK to handle Apple's App Tracking Transparency (ATT) (Platform: IOS)
|
64
|
-
cordova.plugins.emiAdmobPlugin.getIabTfc((IABTFC) => {JSONstringify(IABTFC)}); // CMP SDK 2.2 (Platform: Both)
|
65
|
-
|
66
93
|
// UMP SDK 2.1.0
|
67
94
|
cordova.plugins.emiAdmobPlugin.getConsentRequest(); // (Platform: Both)
|
68
95
|
cordova.plugins.emiAdmobPlugin.consentReset(); // (Platform: Both)
|
69
96
|
cordova.plugins.emiAdmobPlugin.showPrivacyOptionsForm(); // (Platform: Both)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
### AppOpenAd ADS
|
75
|
-
[FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/app_open_ads.html) index.html
|
76
|
-
```
|
77
|
-
<script>
|
78
|
-
// Support Platform: Android | IOS
|
79
|
-
cordova.plugins.emiAdmobPlugin.loadAppOpenAd([config_AppOpenAd]);
|
80
|
-
cordova.plugins.emiAdmobPlugin.showAppOpenAd();
|
81
|
-
</script>
|
82
|
-
```
|
83
|
-
|
84
|
-
|
85
|
-
### BANNER ADS
|
86
|
-
[FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/banner_ads.html) index.html
|
87
|
-
```
|
88
|
-
// Support Platform: Android | IOS
|
89
|
-
<script>
|
90
|
-
cordova.plugins.emiAdmobPlugin.loadBannerAd([bannerConfig]);
|
91
|
-
cordova.plugins.emiAdmobPlugin.showBannerAd();
|
92
|
-
cordova.plugins.emiAdmobPlugin.hideBannerAd();
|
93
|
-
cordova.plugins.emiAdmobPlugin.removeBannerAd();
|
94
|
-
</script>
|
95
|
-
```
|
97
|
+
// CMP SDK 2.2.0
|
98
|
+
cordova.plugins.emiAdmobPlugin.requestIDFA(); // UMP SDK to handle Apple's App Tracking Transparency (ATT) (Platform: IOS)
|
99
|
+
cordova.plugins.emiAdmobPlugin.getIabTfc((IABTFC) => { console.log(JSONstringify(IABTFC)) }); // CMP SDK 2.2 (Platform: Both)
|
96
100
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
<script>
|
102
|
-
cordova.plugins.emiAdmobPlugin.loadInterstitialAd([config_Interstitial]);
|
103
|
-
cordova.plugins.emiAdmobPlugin.showInterstitialAd();
|
104
|
-
</script>
|
105
|
-
```
|
101
|
+
</pre>
|
102
|
+
<details>
|
103
|
+
<summary>Note setDebugGeography #2</summary>
|
104
|
+
Testing is very easy, no need for VPN, TEST-DEVICE-HASHED-ID, or anything else, everything has been made programmatically.
|
106
105
|
|
106
|
+
must be false if the application is released to the play store / app store.
|
107
|
+
consent from will continue to be called regardless of its status 0,1,2,3,
|
108
|
+
until the value is changed to false.
|
107
109
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd([config_rewardedInt]);
|
114
|
-
cordova.plugins.emiAdmobPlugin.showRewardedInterstitialAd();
|
115
|
-
</script>
|
116
|
-
```
|
117
|
-
|
118
|
-
### Rewarded ADS
|
119
|
-
[FULL Rewarded basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/rewarded_ads.html) index.html
|
120
|
-
```
|
121
|
-
// Support Platform: Android | IOS
|
122
|
-
<script>
|
123
|
-
cordova.plugins.emiAdmobPlugin.loadRewardedAd([config_rewarded]);
|
124
|
-
cordova.plugins.emiAdmobPlugin.showRewardedAd();
|
125
|
-
</script>
|
126
|
-
```
|
127
|
-
|
110
|
+
setDebugGeography = true | false
|
111
|
+
</details>
|
112
|
+
<li>example</li></ul>
|
113
|
+
<pre>
|
114
|
+
|
128
115
|
|
116
|
+
document.addEventListener("deviceready", function(){
|
117
|
+
|
118
|
+
const config_globalSettings = [
|
119
|
+
|
120
|
+
setAppMuted = false, // default: false
|
121
|
+
setAppVolume = 1, // float: default: 1
|
122
|
+
enableSameAppKey = false, // default: false
|
123
|
+
npa = "1", // string "0" | "1"
|
124
|
+
enableCollapsible = true, // (BETA) activate the collapsible banner ads
|
125
|
+
responseInfo = false, // default: false
|
126
|
+
setDebugGeography = false // default: false
|
127
|
+
|
128
|
+
]
|
129
|
+
|
130
|
+
cordova.plugins.emiAdmobPlugin.getConsentRequest( (ststus) => { console.log("Consent Status: " + ststus) });
|
131
|
+
cordova.plugins.emiAdmobPlugin.globalSettings(config_globalSettings);
|
132
|
+
|
133
|
+
document.addEventListener('on.get.consent.status', () => {
|
134
|
+
// Regardless of the state, call SDK initialize
|
135
|
+
|
136
|
+
cordova.plugins.emiAdmobPlugin.initialize();
|
137
|
+
cordova.plugins.emiAdmobPlugin.getIabTfc((IABTFC) => { console.log(JSONstringify(IABTFC)) });
|
138
|
+
});
|
129
139
|
|
140
|
+
}, false);
|
130
141
|
|
142
|
+
</pre>
|
131
143
|
|
144
|
+
</details>
|
132
145
|
|
133
146
|
|
134
|
-
|
135
|
-
|
147
|
+
<details>
|
148
|
+
<summary>Event UMP SDK #3</summary>
|
149
|
+
<pre>
|
150
|
+
on.get.consent.status
|
151
|
+
<br>
|
152
|
+
</pre>
|
153
|
+
<li>example:#4</li></ul>
|
154
|
+
<pre>
|
155
|
+
document.addEventListener('on.get.consent.status', () => {
|
136
156
|
|
137
|
-
|
138
|
-
document.addEventListener('on.appOpenAd.loaded', () => {
|
157
|
+
console.log("on get consent status");
|
139
158
|
|
140
|
-
|
159
|
+
});
|
160
|
+
</pre>
|
161
|
+
</details>
|
162
|
+
|
163
|
+
<details>
|
164
|
+
<summary>Event CMP SDK #5</summary>
|
165
|
+
<pre>
|
166
|
+
on.getIabTfc
|
167
|
+
on.TCString.expired
|
168
|
+
on.TCString.remove
|
169
|
+
<br>
|
170
|
+
</pre>
|
171
|
+
|
172
|
+
<details>
|
173
|
+
<summary>Note #6</summary>
|
174
|
+
TCString expires 360 days, plugin automatically deletes it after 360 days. call consentRest()
|
175
|
+
</details>
|
176
|
+
<li>example: #7</li></ul>
|
177
|
+
<pre>
|
178
|
+
document.addEventListener('on.TCString.expired', () => {
|
179
|
+
|
180
|
+
console.log("on TCString expires 360 days");
|
181
|
+
cordova.plugins.emiAdmobPlugin.consentReset();
|
141
182
|
|
142
183
|
});
|
184
|
+
</pre>
|
185
|
+
</details>
|
143
186
|
|
144
|
-
```
|
145
187
|
|
146
|
-
> __Note__
|
147
|
-
### (final) cannot be changed.
|
148
188
|
|
149
|
-
## ( SDK )
|
150
|
-
- on.sdkInitialization
|
151
189
|
|
152
|
-
|
190
|
+
- [AppTrackingTransparency (ATT) framework:](https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus)
|
191
|
+
- [Consent Management Platform API:](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#in-app-details)
|
153
192
|
|
154
|
-
|
193
|
+
- [Example Get Consent Status:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/Advanced%20topics/consent.html) index.html
|
194
|
+
- [Example requestIDFA:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/Advanced%20topics/requestIDFA.html) index.html
|
195
|
+
- [Example IABTFC:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/Advanced%20topics/IABTFC.html) index.html
|
155
196
|
|
156
|
-
- on.appOpenAd.loaded
|
157
|
-
- on.appOpenAd.failed.loaded
|
158
197
|
|
159
|
-
### Event Show
|
160
198
|
|
161
|
-
|
162
|
-
- on.appOpenAd.failed.show
|
163
|
-
- on.appOpenAd.show
|
164
|
-
### NEW
|
165
|
-
- on.appOpenAd.revenue
|
199
|
+
## Global Variable adunitId
|
166
200
|
|
201
|
+
```
|
202
|
+
<script>
|
203
|
+
Ad format Demo ad unit ID
|
204
|
+
// https://developers.google.com/admob/android/test-ads
|
205
|
+
// https://developers.google.com/admob/ios/test-ads
|
206
|
+
|
207
|
+
var App_Open_ID;
|
208
|
+
var Banner_ID;
|
209
|
+
var Interstitial_ID;
|
210
|
+
var Rewarded_ID;
|
211
|
+
var Rewarded_Interstitial_ID;
|
212
|
+
|
213
|
+
if (window.cordova.platformId === 'ios') {
|
214
|
+
|
215
|
+
App_Open_ID = 'ca-app-pub-3940256099942544/5575463023';
|
216
|
+
Banner_ID = 'ca-app-pub-3940256099942544/2934735716';
|
217
|
+
Interstitial_ID = 'ca-app-pub-3940256099942544/4411468910';
|
218
|
+
Rewarded_ID = 'ca-app-pub-3940256099942544/1712485313';
|
219
|
+
Rewarded_Interstitial_ID = 'ca-app-pub-3940256099942544/6978759866';
|
220
|
+
|
221
|
+
} else {
|
222
|
+
// Assume Android
|
223
|
+
App_Open_ID = 'ca-app-pub-3940256099942544/9257395921';
|
224
|
+
Banner_ID = 'ca-app-pub-3940256099942544/6300978111';
|
225
|
+
Interstitial_ID = 'ca-app-pub-3940256099942544/1033173712';
|
226
|
+
Rewarded_ID = 'ca-app-pub-3940256099942544/5224354917';
|
227
|
+
Rewarded_Interstitial_ID = 'ca-app-pub-3940256099942544/5354046379';
|
228
|
+
}
|
229
|
+
</script>
|
230
|
+
```
|
167
231
|
|
168
|
-
## ( Banner Ads )
|
169
232
|
|
170
|
-
|
233
|
+
## AppOpenAd ADS
|
234
|
+
|
235
|
+
<details>
|
236
|
+
<summary>Methods:</summary>
|
237
|
+
<pre>
|
238
|
+
// Support Platform: Android | IOS
|
239
|
+
cordova.plugins.emiAdmobPlugin.loadAppOpenAd([config_AppOpenAd]);
|
240
|
+
cordova.plugins.emiAdmobPlugin.showAppOpenAd();
|
241
|
+
<br>
|
242
|
+
</pre>
|
243
|
+
<li>example:</li></ul>
|
244
|
+
<pre>
|
245
|
+
|
246
|
+
// WARNING config must be an array[] not an object{}
|
247
|
+
// adUnitId = call Global Variable
|
248
|
+
|
249
|
+
cordova.plugins.emiAdmobPlugin.loadAppOpenAd([ adUnitId = App_Open_ID, autoShow = true ]);
|
250
|
+
</pre>
|
251
|
+
</details>
|
252
|
+
|
253
|
+
<details>
|
254
|
+
<summary>Event</summary>
|
255
|
+
<pre>
|
256
|
+
on.appOpenAd.loaded
|
257
|
+
on.appOpenAd.failed.loaded
|
258
|
+
on.appOpenAd.dismissed
|
259
|
+
on.appOpenAd.failed.show
|
260
|
+
on.appOpenAd.show
|
261
|
+
on.appOpenAd.revenue
|
262
|
+
<br>
|
263
|
+
</pre>
|
264
|
+
<li>example:</li></ul>
|
265
|
+
<pre>
|
266
|
+
document.addEventListener('on.appOpenAd.loaded', () => {
|
171
267
|
|
172
|
-
|
173
|
-
- top-center
|
174
|
-
- left
|
175
|
-
- center
|
176
|
-
- right
|
177
|
-
- bottom-center
|
178
|
-
- bottom-right
|
268
|
+
console.log("On App Open Ad loaded");
|
179
269
|
|
270
|
+
});
|
271
|
+
</pre>
|
272
|
+
</details>
|
180
273
|
|
274
|
+
- [FULL AppOpenAd basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/app_open_ads.html) -index.html
|
181
275
|
|
182
|
-
### size
|
183
276
|
|
184
|
-
- ANCHORED
|
185
|
-
- IN_LINE
|
186
|
-
- FULL_WIDTH
|
187
|
-
- BANNER
|
188
|
-
- FLUID
|
189
|
-
- LARGE_BANNER
|
190
|
-
- MEDIUM_RECTANGLE
|
191
|
-
- FULL_BANNER
|
192
|
-
- LEADERBOARD
|
193
|
-
- adaptive_Width = number
|
194
|
-
- Smart Banners = DEPRECATED
|
195
277
|
|
278
|
+
|
279
|
+
## BANNER ADS
|
196
280
|
|
197
|
-
|
281
|
+
<details>
|
282
|
+
<summary>Methods:</summary>
|
283
|
+
<pre>
|
284
|
+
cordova.plugins.emiAdmobPlugin.loadBannerAd([bannerConfig]);
|
285
|
+
cordova.plugins.emiAdmobPlugin.showBannerAd();
|
286
|
+
cordova.plugins.emiAdmobPlugin.hideBannerAd();
|
287
|
+
cordova.plugins.emiAdmobPlugin.removeBannerAd();
|
288
|
+
</pre>
|
289
|
+
<li>example:</li></ul>
|
290
|
+
<pre>
|
291
|
+
// WARNING config must be an array[] not an object{}
|
292
|
+
// adUnitId = call Global Variable
|
293
|
+
|
294
|
+
const bannerConfig = [
|
295
|
+
|
296
|
+
adUnitId = Banner_ID,
|
297
|
+
position = "bottom-center",
|
298
|
+
size = "BANNER",
|
299
|
+
collapsible = "bottom", // (BETA) enable in globalSettings
|
300
|
+
adaptive_Width = 320, // Ignored
|
301
|
+
autoShow = true // boolean
|
302
|
+
|
303
|
+
]
|
304
|
+
|
305
|
+
cordova.plugins.emiAdmobPlugin.loadBannerAd(bannerConfig);
|
306
|
+
|
307
|
+
</pre>
|
308
|
+
</details>
|
309
|
+
|
310
|
+
<details>
|
311
|
+
<summary>Position type string</summary>
|
312
|
+
<pre>
|
313
|
+
top-right
|
314
|
+
top-center
|
315
|
+
left
|
316
|
+
center
|
317
|
+
right
|
318
|
+
bottom-center
|
319
|
+
bottom-right
|
320
|
+
</pre>
|
321
|
+
</details>
|
322
|
+
|
323
|
+
<details>
|
324
|
+
<summary>Size type string</summary>
|
325
|
+
<pre>
|
326
|
+
ANCHORED
|
327
|
+
IN_LINE
|
328
|
+
FULL_WIDTH
|
329
|
+
BANNER
|
330
|
+
FLUID
|
331
|
+
LARGE_BANNER
|
332
|
+
MEDIUM_RECTANGLE
|
333
|
+
FULL_BANNER
|
334
|
+
LEADERBOARD
|
335
|
+
adaptive_Width = number
|
336
|
+
</pre>
|
337
|
+
</details>
|
338
|
+
|
339
|
+
<details>
|
340
|
+
<summary>Event</summary>
|
341
|
+
<pre>
|
342
|
+
on.banner.load
|
343
|
+
on.banner.failed.load
|
344
|
+
on.banner.click
|
345
|
+
on.banner.close
|
346
|
+
on.banner.impression
|
347
|
+
on.banner.open
|
348
|
+
// new
|
349
|
+
on.banner.revenue
|
350
|
+
on.banner.remove
|
351
|
+
on.banner.hide
|
352
|
+
</pre>
|
353
|
+
<li>example:</li></ul>
|
354
|
+
<pre>
|
355
|
+
document.addEventListener('on.banner.load', () => {
|
356
|
+
|
357
|
+
console.log("on banner load");
|
358
|
+
|
359
|
+
});</pre>
|
360
|
+
</details>
|
198
361
|
|
199
|
-
-
|
200
|
-
- on.banner.failed.load
|
362
|
+
[FULL Banner basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/banner_ads.html) index.html
|
201
363
|
|
202
|
-
### Event Show
|
203
364
|
|
204
|
-
|
205
|
-
- on.banner.close
|
206
|
-
- on.banner.impression
|
207
|
-
- on.banner.open
|
208
|
-
### NEW
|
209
|
-
- on.banner.revenue
|
210
|
-
- on.banner.remove
|
211
|
-
- on.banner.hide
|
212
|
-
|
365
|
+
## Interstitial ADS
|
213
366
|
|
214
367
|
|
368
|
+
<details>
|
369
|
+
<summary>Methods:</summary>
|
370
|
+
<pre>
|
371
|
+
// Support Platform: Android | IOS
|
372
|
+
cordova.plugins.emiAdmobPlugin.loadInterstitialAd([config_Interstitial]);
|
373
|
+
cordova.plugins.emiAdmobPlugin.showInterstitialAd();
|
374
|
+
<br>
|
375
|
+
</pre>
|
376
|
+
<li>example:</li></ul>
|
377
|
+
<pre>
|
378
|
+
|
379
|
+
// WARNING config must be an array[] not an object{}
|
380
|
+
// adUnitId = call Global Variable
|
381
|
+
|
382
|
+
cordova.plugins.emiAdmobPlugin.loadInterstitialAd([ adUnitId = Interstitial_ID, autoShow = true ]);
|
383
|
+
</pre>
|
384
|
+
</details>
|
385
|
+
|
386
|
+
<details>
|
387
|
+
<summary>Event</summary>
|
388
|
+
<pre>
|
389
|
+
on.interstitial.loaded
|
390
|
+
on.interstitial.failed.load
|
391
|
+
on.interstitial.click
|
392
|
+
on.interstitial.dismissed
|
393
|
+
on.interstitial.failed.show
|
394
|
+
on.interstitial.impression
|
395
|
+
on.interstitial.show
|
396
|
+
// new
|
397
|
+
on.interstitial.revenue
|
398
|
+
<br>
|
399
|
+
</pre>
|
400
|
+
<li>example:</li></ul>
|
401
|
+
<pre>
|
402
|
+
document.addEventListener('on.interstitial.loaded', () => {
|
403
|
+
|
404
|
+
console.log("on interstitial Ad loaded");
|
215
405
|
|
216
|
-
|
406
|
+
});
|
407
|
+
</pre>
|
408
|
+
</details>
|
217
409
|
|
218
|
-
### Event Load
|
219
410
|
|
220
|
-
-
|
221
|
-
- on.interstitial.failed.load
|
411
|
+
[FULL Interstitial basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/interstitial_ads.html) index.html
|
222
412
|
|
223
|
-
### Event Show
|
224
413
|
|
225
|
-
- on.interstitial.click
|
226
|
-
- on.interstitial.dismissed
|
227
|
-
- on.interstitial.failed.show
|
228
|
-
- on.interstitial.impression
|
229
|
-
- on.interstitial.show
|
230
|
-
### NEW
|
231
|
-
- on.interstitial.revenue
|
232
414
|
|
233
415
|
|
416
|
+
## Rewarded Interstitial ADS
|
234
417
|
|
235
418
|
|
236
419
|
|
237
|
-
|
420
|
+
<details>
|
421
|
+
<summary>Methods:</summary>
|
422
|
+
<pre>
|
423
|
+
// Support Platform: Android | IOS
|
424
|
+
cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd([config_rewardedInt]);
|
425
|
+
cordova.plugins.emiAdmobPlugin.showRewardedInterstitialAd();
|
426
|
+
<br>
|
427
|
+
</pre>
|
428
|
+
<li>example:</li></ul>
|
429
|
+
<pre>
|
430
|
+
|
431
|
+
// WARNING config must be an array[] not an object{}
|
432
|
+
// adUnitId = call Global Variable
|
433
|
+
|
434
|
+
cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd([ adUnitId = Rewarded_Interstitial_ID, autoShow = true ]);
|
435
|
+
</pre>
|
436
|
+
</details>
|
437
|
+
|
438
|
+
<details>
|
439
|
+
<summary>Event</summary>
|
440
|
+
<pre>
|
441
|
+
on.rewardedInt.loaded
|
442
|
+
on.rewardedInt.failed.load
|
443
|
+
on.rewardedInt.click
|
444
|
+
on.rewardedInt.dismissed
|
445
|
+
on.rewardedInt.failed.show
|
446
|
+
on.rewardedInt.impression
|
447
|
+
on.rewardedInt.showed
|
448
|
+
on.rewardedInt.userEarnedReward
|
449
|
+
// new
|
450
|
+
on.rewardedInt.revenue
|
451
|
+
on.rewardedInt.ad.skip
|
452
|
+
<br>
|
453
|
+
</pre>
|
454
|
+
<li>example:</li></ul>
|
455
|
+
<pre>
|
456
|
+
document.addEventListener('on.rewardedInt.loaded', () => {
|
457
|
+
|
458
|
+
console.log("on rewarded Interstitial load");
|
238
459
|
|
239
|
-
|
460
|
+
});
|
461
|
+
</pre>
|
462
|
+
</details>
|
240
463
|
|
241
|
-
-
|
242
|
-
- on.rewarded.failed.load
|
464
|
+
[FULL Rewarded Interstitial basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/rewarded_interstitial_ads.html) index.html
|
243
465
|
|
244
466
|
|
245
|
-
### Event Show
|
246
467
|
|
247
|
-
|
248
|
-
- on.rewarded.dismissed
|
249
|
-
- on.rewarded.failed.show
|
250
|
-
- on.rewarded.impression
|
251
|
-
- on.rewarded.show
|
252
|
-
### NEW
|
253
|
-
- on.rewarded.revenue
|
254
|
-
- on.rewarded.ad.skip
|
255
|
-
- on.reward.userEarnedReward
|
468
|
+
## Rewarded ADS
|
256
469
|
|
257
470
|
|
258
471
|
|
259
|
-
|
472
|
+
<details>
|
473
|
+
<summary>Methods:</summary>
|
474
|
+
<pre>
|
475
|
+
// Support Platform: Android | IOS
|
476
|
+
cordova.plugins.emiAdmobPlugin.loadRewardedAd([config_rewarded]);
|
477
|
+
cordova.plugins.emiAdmobPlugin.showRewardedAd();
|
478
|
+
<br>
|
479
|
+
</pre>
|
480
|
+
<li>example:</li></ul>
|
481
|
+
<pre>
|
482
|
+
// adUnitId = call Global Variable
|
483
|
+
|
484
|
+
cordova.plugins.emiAdmobPlugin.loadRewardedAd([ adUnitId = Rewarded_ID, autoShow = true ]);
|
485
|
+
</pre>
|
486
|
+
</details>
|
487
|
+
|
488
|
+
<details>
|
489
|
+
<summary>Event</summary>
|
490
|
+
<pre>
|
491
|
+
on.rewarded.loaded
|
492
|
+
on.rewarded.failed.load
|
493
|
+
on.rewarded.click
|
494
|
+
on.rewarded.dismissed
|
495
|
+
on.rewarded.failed.show
|
496
|
+
on.rewarded.impression
|
497
|
+
on.rewarded.show
|
498
|
+
on.reward.userEarnedReward
|
499
|
+
// new
|
500
|
+
on.rewarded.revenue
|
501
|
+
on.rewarded.ad.skip
|
502
|
+
|
503
|
+
<br>
|
504
|
+
</pre>
|
505
|
+
<li>example:</li></ul>
|
506
|
+
<pre>
|
507
|
+
document.addEventListener('on.rewarded.loaded', () => {
|
508
|
+
|
509
|
+
console.log("on rewarded Ad loaded");
|
260
510
|
|
261
|
-
|
511
|
+
});
|
512
|
+
</pre>
|
513
|
+
</details>
|
262
514
|
|
263
|
-
-
|
264
|
-
- on.rewardedInt.failed.load
|
515
|
+
[FULL Rewarded basic:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/rewarded_ads.html) index.html
|
265
516
|
|
266
517
|
|
267
|
-
### Event Show
|
268
518
|
|
269
|
-
- on.rewardedInt.click
|
270
|
-
- on.rewardedInt.dismissed
|
271
|
-
- on.rewardedInt.failed.show
|
272
|
-
- on.rewardedInt.impression
|
273
|
-
- on.rewardedInt.showed
|
274
|
-
### NEW
|
275
|
-
- on.rewardedInt.revenue
|
276
|
-
- on.rewardedInt.ad.skip
|
277
|
-
- on.rewardedInt.userEarnedReward
|
278
519
|
|
279
520
|
|
280
521
|
|
281
522
|
|
282
523
|
|
283
|
-
> __Note__
|
284
|
-
> - ## It's Not a fork, it's purely rewritten, clean of 3rd party code.
|
285
524
|
|
286
|
-
> __Note__
|
287
|
-
> - ### No Ad-Sharing
|
288
|
-
> - ### No Remote Control
|
289
|
-
> - ### I guarantee 100% revenue for you.
|
290
|
-
> - [Code source:](https://github.com/googleads/googleads-mobile-android-examples) - Admob:
|
291
525
|
|
292
526
|
|
293
|
-
## 💰Sponsor this project
|
294
|
-
[](https://paypal.me/emiindo)
|
295
|
-
|
296
|
-
## [Check all release notes:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/)
|
297
527
|
|
298
528
|
|
299
529
|
|
300
530
|
|
531
|
+
<details>
|
532
|
+
<summary>Features and Coming soon #13</summary>
|
533
|
+
|
301
534
|
## Features
|
302
535
|
|
303
536
|
- SDK initialize
|
@@ -326,38 +559,16 @@ alert("On App Open Ad loaded");
|
|
326
559
|
- https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/ ( Finished ) v1.4.0 [index.html](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/Advanced%20topics/consent_GDPR_IAB_TFCv2.2.html)
|
327
560
|
|
328
561
|
|
562
|
+
</details>
|
329
563
|
|
330
564
|
|
331
565
|
|
332
566
|
|
333
567
|
|
334
|
-
|
335
|
-
> __Note__
|
336
|
-
>
|
337
|
-
|
338
|
-
> - # Plugin version @1.4.0
|
339
|
-
|
340
|
-
### [ GDPR | IAB TFC code example: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/Advanced%20topics/consent_GDPR_IAB_TFCv2.2.html)
|
341
|
-
- replace all AdUnitId to adUnitId
|
342
|
-
- new banner size: FULL_WIDTH
|
343
|
-
### New only on github
|
344
|
-
https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/%401.4.0
|
345
|
-
|
346
|
-
> - # Plugin version @1.3.9
|
347
|
-
|
348
|
-
[FULL Example ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/) - index.html:
|
349
|
-
|
350
|
-
### [ App Open Ad code example: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/app_open_ads.html)
|
351
|
-
### [ Banner Ad code example: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/banner_ads.html)
|
352
|
-
### [ Interstitial Ad code example: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/interstitial_ads.html)
|
353
|
-
### [ Rewarded interstitial Ad code example: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/rewarded_interstitial_ads.html)
|
354
|
-
### [ Rewarded Ad code example: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/rewarded_ads.html)
|
355
|
-
|
356
|
-
### [ Advanced topics: ](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/tree/main/example/Advanced%20topics)
|
357
|
-
|
358
568
|
# IAB Europe Transparency & Consent Framework
|
359
|
-
### Example How to read consent choices
|
360
569
|
|
570
|
+
<details>
|
571
|
+
<summary>Example How to read consent choices #12</summary>
|
361
572
|
|
362
573
|
// index.html https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/Advanced%20topics/consent_GDPR_IAB_TFCv2.2.html
|
363
574
|
```sh
|
@@ -408,11 +619,17 @@ alert("On App Open Ad loaded");
|
|
408
619
|
|
409
620
|
```
|
410
621
|
|
411
|
-
|
622
|
+
</details>
|
412
623
|
|
413
624
|
|
414
625
|
|
415
626
|
# Admob Mediation
|
627
|
+
|
628
|
+
<details>
|
629
|
+
<summary>Mediation #9</summary>
|
630
|
+
|
631
|
+
|
632
|
+
|
416
633
|
<img src="https://user-images.githubusercontent.com/78555833/229587307-91a7e380-aa2d-4140-a62d-fa8e6a8dd153.png" width="500">
|
417
634
|
|
418
635
|
|
@@ -487,10 +704,16 @@ cordova plugin add emi-indo-cordova-plugin-mediation-chartboost
|
|
487
704
|
```sh
|
488
705
|
cordova plugin add emi-indo-cordova-plugin-mediation-ironsource
|
489
706
|
```
|
707
|
+
</details>
|
490
708
|
|
491
709
|
|
492
710
|
|
493
711
|
## Variables name or preference name
|
712
|
+
|
713
|
+
<details>
|
714
|
+
<summary>Variables name #10</summary>
|
715
|
+
|
716
|
+
|
494
717
|
> __Warning__
|
495
718
|
> This is so that if I don't have time to update the Mediation Adapter version later, you can do it yourself as below.
|
496
719
|
|
@@ -522,24 +745,10 @@ cordova plugin add emi-indo-cordova-plugin-mediation-meta --variable META_ADAPTE
|
|
522
745
|
- IRONSOURCE_ADAPTER_VERSION
|
523
746
|
|
524
747
|
- ================================
|
748
|
+
</details>
|
525
749
|
|
526
750
|
|
527
|
-
emi-indo-cordova-plugin-admob@0.0.5
|
528
751
|
|
529
|
-
|
530
|
-
> - ## Note Release
|
531
|
-
- [emi-indo-cordova-plugin-admob@0.0.4](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/%400.0.4)
|
532
|
-
|
533
|
-
- [emi-indo-cordova-plugin-admob@0.0.5](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/v0.0.5)
|
534
|
-
|
535
|
-
<img src="https://user-images.githubusercontent.com/78555833/231241800-8834ca2a-fa95-4cc2-91ca-1478c6b3c1ef.jpg" width="250">
|
536
|
-
|
537
|
-
- [emi-indo-cordova-plugin-admob@0.0.6](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/v0.0.6)
|
538
|
-
|
539
|
-
|
540
|
-
### Platform Support
|
541
|
-
- Android
|
542
|
-
- IOS
|
543
752
|
|
544
753
|
|
545
754
|
## 💰Sponsor this project
|
@@ -547,6 +756,10 @@ emi-indo-cordova-plugin-admob@0.0.5
|
|
547
756
|
|
548
757
|
|
549
758
|
## Earn more money, with other ad networks.
|
759
|
+
|
760
|
+
<details>
|
761
|
+
<summary>Other plugins #11</summary>
|
762
|
+
|
550
763
|
- ### emi-indo-cordova-plugin-fan
|
551
764
|
|
552
765
|
[Facebook Audience Network:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-fan) - Ads:
|
@@ -567,4 +780,4 @@ emi-indo-cordova-plugin-admob@0.0.5
|
|
567
780
|
- ### emi-indo-cordova-plugin-fanalytics
|
568
781
|
|
569
782
|
[Cordova Plugin Firebase Analytics:](https://github.com/EMI-INDO/emi-indo-cordova-plugin-fanalytics) - Firebase Analytics:
|
570
|
-
|
783
|
+
</details>
|
package/example/banner_ads.html
CHANGED
@@ -71,7 +71,21 @@ let loadBannerAd = () => {
|
|
71
71
|
// show Banner Ad
|
72
72
|
let showBannerAd = () => {
|
73
73
|
|
74
|
-
cordova.plugins.emiAdmobPlugin.showBannerAd()
|
74
|
+
cordova.plugins.emiAdmobPlugin.showBannerAd((info) => {
|
75
|
+
document.body.style.height= '93vh';
|
76
|
+
document.body.style.background= 'black';
|
77
|
+
// event name: on.banner.revenue
|
78
|
+
event.value += "\n Micros: " + info.micros;
|
79
|
+
event.value += "\n Currency: " + info.currency;
|
80
|
+
event.value += "\n Precision: " + info.precision;
|
81
|
+
event.value += "\n AdUnitId: " + info.adUnitId;
|
82
|
+
|
83
|
+
},
|
84
|
+
(error) => {
|
85
|
+
|
86
|
+
event.value += "\n Error: " + error
|
87
|
+
|
88
|
+
});
|
75
89
|
// call showBannerAd();
|
76
90
|
}
|
77
91
|
|
File without changes
|
package/package.json
CHANGED
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.4.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="1.4.4">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova Plugin Admob Android IOS</description>
|
@@ -1 +1 @@
|
|
1
|
-
package emi.indo.cordova.plugin.admob;import android.app.Activity;import android.content.Context;import android.content.SharedPreferences;import android.content.res.Configuration;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.ViewGroup;import android.widget.RelativeLayout;import androidx.annotation.NonNull;import androidx.preference.PreferenceManager;import com.google.ads.mediation.admob.AdMobAdapter;import com.google.android.gms.ads.AdError;import com.google.android.gms.ads.AdListener;import com.google.android.gms.ads.AdRequest;import com.google.android.gms.ads.AdSize;import com.google.android.gms.ads.AdValue;import com.google.android.gms.ads.AdView;import com.google.android.gms.ads.FullScreenContentCallback;import com.google.android.gms.ads.LoadAdError;import com.google.android.gms.ads.MobileAds;import com.google.android.gms.ads.OnPaidEventListener;import com.google.android.gms.ads.RequestConfiguration;import com.google.android.gms.ads.ResponseInfo;import com.google.android.gms.ads.appopen.AppOpenAd;import com.google.android.gms.ads.initialization.AdapterStatus;import com.google.android.gms.ads.interstitial.InterstitialAd;import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;import com.google.android.gms.ads.rewarded.RewardedAd;import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback;import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd;import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback;import com.google.android.ump.ConsentForm;import com.google.android.ump.ConsentInformation;import com.google.android.ump.ConsentRequestParameters;import com.google.android.ump.UserMessagingPlatform;import org.apache.cordova.CallbackContext;import org.apache.cordova.CordovaInterface;import org.apache.cordova.CordovaPlugin;import org.apache.cordova.CordovaWebView;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import java.util.Map;import java.util.Objects;public class emiAdmobPlugin extends CordovaPlugin{private static final String TAG="emiAdmobPlugin";private CallbackContext PUBLIC_CALLBACKS=null;private InterstitialAd mInterstitialAd;private RewardedAd rewardedAd;private RewardedInterstitialAd rewardedInterstitialAd;private CordovaWebView cWebView;private boolean isAppOpenAdShow=false;static boolean isinterstitialload=false;static boolean isrewardedInterstitialload=false;static boolean isrewardedload=false;int isBannerPause=0;String Npa;String Position;String Size;int AdaptiveWidth=320;Boolean ResponseInfo=false;int bannerAdImpression=0;private int isAdSkip=0;int SetTagForChildDirectedTreatment=-1;Boolean SetTagForUnderAgeOfConsent=false;String SetMaxAdContentRating="G";String appOpenAdUnitId;String bannerAdUnitId;String interstitialAdUnitId;String rewardedInterstitialAdUnitId;String rewardedAdUnitId;boolean SetAppMuted=false;float SetAppVolume=1;boolean EnableSameAppKey=false;private ConsentInformation consentInformation;private RelativeLayout bannerViewLayout;private AdView bannerView;private boolean isBannerLoad=false;private boolean isBannerShow=false;Boolean bannerAutoShow=false;Boolean appOpenAutoShow=false;Boolean intAutoShow=false;Boolean rewardedAutoShow=false;Boolean rIntAutoShow=false;String Collapsible;Boolean isCollapsible=false;Boolean lock=true;protected Activity mActivity;protected Context mContext;private AppOpenAd appOpenAd;int orientation=0;public void initialize(CordovaInterface cordova,CordovaWebView webView){super.initialize(cordova,webView);cWebView=webView;mActivity=this.cordova.getActivity();mContext=mActivity.getApplicationContext();int orientation=mActivity.getResources().getConfiguration().orientation;if(orientation==Configuration.ORIENTATION_PORTRAIT){this.orientation=0;}else{this.orientation=1;}}public boolean execute(String action,JSONArray args,final CallbackContext callbackContext)throws JSONException{PUBLIC_CALLBACKS=callbackContext;switch(action){case "initialize":Log.d(TAG,"Google Mobile Ads SDK: "+MobileAds.getVersion());MobileAds.initialize(mActivity,initializationStatus ->{Map<String,AdapterStatus> statusMap=initializationStatus.getAdapterStatusMap();for(String adapterClass:statusMap.keySet()){AdapterStatus status=statusMap.get(adapterClass);if(status!=null){Log.d(TAG,String.format("Adapter name:%s,Description:%s,Latency:%d",adapterClass,status.getDescription(),status.getLatency()));}else{callbackContext.error(MobileAds.ERROR_DOMAIN);}}callbackContext.success("Google Mobile Ads SDK: "+MobileAds.getVersion());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization');");});return true;case "targeting":cordova.getActivity().runOnUiThread(()->{final int childDirectedTreatment=args.optInt(0);final boolean underAgeOfConsent=args.optBoolean(1);final String contentRating=args.optString(2);try{this.SetTagForChildDirectedTreatment=childDirectedTreatment;this.SetTagForUnderAgeOfConsent=underAgeOfConsent;this.SetMaxAdContentRating=contentRating;_Targeting();}catch(Exception e){callbackContext.error(e.toString());}});return true;case "globalSettings":cordova.getActivity().runOnUiThread(()->{final boolean setAppMuted=args.optBoolean(0);final float setAppVolume=(float)args.optDouble(1);final boolean publisherFirstPartyIdEnabled=args.optBoolean(2);final String npa=args.optString(3);final boolean enableCollapsible=args.optBoolean(4);final boolean responseInfo=args.optBoolean(5);try{this.SetAppMuted=setAppMuted;this.SetAppVolume=setAppVolume;this.EnableSameAppKey=publisherFirstPartyIdEnabled;this.Npa=npa;this.isCollapsible=enableCollapsible;this.ResponseInfo=responseInfo;_globalSettings();}catch(Exception e){callbackContext.error(e.toString());}});return true;case "loadAppOpenAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final boolean autoShow=args.optBoolean(1);try{this.appOpenAdUnitId=adUnitId;this.appOpenAutoShow=autoShow;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();AppOpenAd.load(mActivity,this.appOpenAdUnitId,adRequest,new AppOpenAd.AppOpenAdLoadCallback(){@Override public void onAdLoaded(@NonNull AppOpenAd ad){appOpenAd=ad;isAppOpenAdShow=true;if(appOpenAutoShow){cordova.getActivity().runOnUiThread(()-> appOpenAd.show(mActivity));_appOpenAdLoadCallback(callbackContext);}appOpenAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=appOpenAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.revenue');");}catch(JSONException e){callbackContext.error(e.getMessage());}});cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.loaded');");if(ResponseInfo){JSONObject result=new JSONObject();ResponseInfo responseInfo=appOpenAd.getResponseInfo();try{result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getLoadedAdapter",responseInfo.getLoadedAdapterResponseInfo());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("bundleExtra",bundleExtra);PUBLIC_CALLBACKS.success(result);}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){isAppOpenAdShow=false;callbackContext.error(loadAdError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded');");}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showAppOpenAd":if(isAppOpenAdShow){_appOpenAdLoadCallback(callbackContext);cordova.getActivity().runOnUiThread(()-> appOpenAd.show(mActivity));}else{callbackContext.error("The App Open Ad wasn't ready yet");}return true;case "loadInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final boolean autoShow=args.optBoolean(1);try{this.interstitialAdUnitId=adUnitId;this.intAutoShow=autoShow;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();InterstitialAd.load(mActivity,this.interstitialAdUnitId,adRequest,new InterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd){isinterstitialload=true;mInterstitialAd=interstitialAd;if(intAutoShow){_interstitialAdLoadCallback(callbackContext);cordova.getActivity().runOnUiThread(()-> mInterstitialAd.show(mActivity));}Log.i(TAG,"onAdLoaded");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.loaded');");if(ResponseInfo){JSONObject result=new JSONObject();ResponseInfo responseInfo=interstitialAd.getResponseInfo();try{result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getLoadedAdapter",responseInfo.getLoadedAdapterResponseInfo());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("bundleExtra",bundleExtra);PUBLIC_CALLBACKS.success(result);}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}mInterstitialAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=mInterstitialAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.revenue');");});}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.load');");callbackContext.error(loadAdError.toString());}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showInterstitialAd":if(isinterstitialload){_interstitialAdLoadCallback(callbackContext);cordova.getActivity().runOnUiThread(()-> mInterstitialAd.show(mActivity));}else{callbackContext.error("The Interstitial ad wasn't ready yet");}return true;case "loadRewardedAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final boolean autoShow=args.optBoolean(1);try{this.rewardedAdUnitId=adUnitId;this.rewardedAutoShow=autoShow;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedAd.load(mActivity,this.rewardedAdUnitId,adRequest,new RewardedAdLoadCallback(){public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.load');");callbackContext.error(loadAdError.toString());}@Override public void onAdLoaded(@NonNull RewardedAd ad){rewardedAd=ad;isrewardedload=true;isAdSkip=0;if(rewardedAutoShow){isAdSkip=1;rewardedAd.show(mActivity,rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});_rewardedAdLoadCallback(callbackContext);}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.loaded');");if(ResponseInfo){JSONObject result=new JSONObject();ResponseInfo responseInfo=ad.getResponseInfo();try{result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getLoadedAdapter",responseInfo.getLoadedAdapterResponseInfo());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("bundleExtra",bundleExtra);PUBLIC_CALLBACKS.success(result);}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}rewardedAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=rewardedAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.revenue');");});}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showRewardedAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedload){isAdSkip=1;rewardedAd.show(mActivity,rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});_rewardedAdLoadCallback(callbackContext);}else{callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "loadRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final boolean autoShow=args.optBoolean(1);try{this.rewardedInterstitialAdUnitId=adUnitId;this.rIntAutoShow=autoShow;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedInterstitialAd.load(mActivity,this.rewardedInterstitialAdUnitId,adRequest,new RewardedInterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull RewardedInterstitialAd ad){rewardedInterstitialAd=ad;isrewardedInterstitialload=true;isAdSkip=0;if(rIntAutoShow){isAdSkip=1;rewardedInterstitialAd.show(mActivity,rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});_rewardedInterstitialAdLoadCallback(callbackContext);}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.loaded');");if(ResponseInfo){JSONObject result=new JSONObject();ResponseInfo responseInfo=ad.getResponseInfo();try{result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getLoadedAdapter",responseInfo.getLoadedAdapterResponseInfo());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("bundleExtra",bundleExtra);PUBLIC_CALLBACKS.success(result);}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}rewardedInterstitialAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=rewardedInterstitialAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.revenue');");});}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load');");callbackContext.error(loadAdError.toString());}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedInterstitialload){isAdSkip=1;rewardedInterstitialAd.show(mActivity,rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{callbackContext.error("The rewarded ad wasn't ready yet");}_rewardedInterstitialAdLoadCallback(callbackContext);});return true;case "loadBannerAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final String position=args.optString(1);final String size=args.optString(2);final String collapsible=args.optString(3);final int adaptive_Width=args.optInt(4);final boolean autoShow=args.optBoolean(5);try{this.bannerAdUnitId=adUnitId;this.Position=position;this.Size=size;this.AdaptiveWidth=adaptive_Width;this.Collapsible=collapsible;this.bannerAutoShow=autoShow;if(lock){_loadBannerAd(adUnitId,position,size,collapsible,adaptive_Width);}}catch(Exception e){callbackContext.error(e.toString());}});return true;case "getConsentRequest":cordova.getActivity().runOnUiThread(()->{try{ConsentRequestParameters params=new ConsentRequestParameters .Builder().build();consentInformation=UserMessagingPlatform.getConsentInformation(mActivity);consentInformation.requestConsentInfoUpdate(mActivity,params,()->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update');");if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.NOT_REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.NOT_REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.not_required');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.OBTAINED){callbackContext.success(ConsentInformation.ConsentStatus.OBTAINED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.obtained');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.required');");if(consentInformation.isConsentFormAvailable()){UserMessagingPlatform.loadConsentForm(cordova.getContext(),consentForm -> consentForm.show(cordova.getActivity(),formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show');");callbackContext.error(String.valueOf(formError));}),formError -> callbackContext.error(formError.getMessage()));cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from');");}else{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.form.not.available');");}}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.UNKNOWN){callbackContext.success(ConsentInformation.ConsentStatus.UNKNOWN);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.unknown');");}},formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed');");callbackContext.error(formError.getMessage());});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showPrivacyOptionsForm":cordova.getActivity().runOnUiThread(this::consentInfoUpdate);return true;case "consentReset":cordova.getActivity().runOnUiThread(()->{if(consentInformation!=null){consentInformation.reset();}});return true;case "getIabTfc":cordova.getActivity().runOnUiThread(()->{Context context=this.cordova.getActivity().getApplicationContext();SharedPreferences mPreferences=PreferenceManager.getDefaultSharedPreferences(context);int gdprApplies=mPreferences.getInt("IABTCF_gdprApplies",0);String consentString=mPreferences.getString("IABTCF_TCString","");String purposeConsents=mPreferences.getString("IABTCF_PurposeConsents","");JSONObject userInfoJson=new JSONObject();try{userInfoJson.put("IABTCF_TCString",consentString);userInfoJson.put("IABTCF_PurposeConsents",purposeConsents);userInfoJson.put("IABTCF_gdprApplies",gdprApplies);callbackContext.success(userInfoJson);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc');");}catch(Exception e){callbackContext.error(e.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc.error');");}});return true;case "showBannerAd":cordova.getActivity().runOnUiThread(()->{if(isBannerPause==0){if(isBannerLoad){bannerViewLayout.addView(bannerView);isBannerShow=true;}}else if(isBannerPause==1){bannerView.setVisibility(View.VISIBLE);bannerView.resume();}});return true;case "hideBannerAd":cordova.getActivity().runOnUiThread(()->{if(isBannerShow){try{bannerView.setVisibility(View.GONE);bannerView.pause();isBannerLoad=false;isBannerPause=1;}catch(Exception e){callbackContext.error(e.toString());}}});return true;case "removeBannerAd":cordova.getActivity().runOnUiThread(()->{if(bannerView==null)return;RelativeLayout bannerViewLayout=(RelativeLayout)bannerView.getParent();if(bannerViewLayout!=null){bannerViewLayout.removeView(bannerView);bannerView.destroy();bannerView=null;isBannerLoad=false;isBannerShow=false;isBannerPause=2;lock=true;bannerAdImpression=0;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.remove');");}});return true;}return false;}private void _loadBannerAd(String adUnitId,String position,String size,String collapsible,int adaptive_Width){try{if(bannerViewLayout==null){bannerViewLayout=new RelativeLayout(mActivity);RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);try{((ViewGroup)(((View)Objects.requireNonNull(webView.getClass().getMethod("getView").invoke(webView))).getParent())).addView(bannerViewLayout,params);}catch(Exception e){((ViewGroup)webView).addView(bannerViewLayout,params);}}bannerView=new AdView(mActivity);if(Objects.equals(size,"BANNER")){bannerView.setAdSize(AdSize.BANNER);}else if(Objects.equals(size,"LARGE_BANNER")){bannerView.setAdSize(AdSize.LARGE_BANNER);}else if(Objects.equals(size,"MEDIUM_RECTANGLE")){bannerView.setAdSize(AdSize.MEDIUM_RECTANGLE);}else if(Objects.equals(size,"FULL_BANNER")){bannerView.setAdSize(AdSize.FULL_BANNER);}else if(Objects.equals(size,"LEADERBOARD")){bannerView.setAdSize(AdSize.LEADERBOARD);}else if(Objects.equals(size,"FLUID")){bannerView.setAdSize(AdSize.FLUID);}else if(Objects.equals(size,"ANCHORED")){bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(mActivity,adaptive_Width));}else if(Objects.equals(size,"IN_LINE")){bannerView.setAdSize(AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(mActivity,adaptive_Width));}else if(Objects.equals(size,"FULL_WIDTH")){bannerView.setAdSize(AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(mActivity,AdSize.FULL_WIDTH));}else{bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(mActivity,AdSize.FULL_WIDTH));}bannerView.setAdUnitId(adUnitId);Bundle bundleExtra=new Bundle();if(isCollapsible){bundleExtra.putString("collapsible",collapsible);}bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();bannerView.loadAd(adRequest);bannerView.setAdListener(bannerAdListener);RelativeLayout.LayoutParams bannerParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);switch(position){case "top-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;case "top-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "left":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "center":bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "bottom-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "bottom-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;default:bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);break;}bannerView.setLayoutParams(bannerParams);bannerViewLayout.bringToFront();}catch(Exception e){PUBLIC_CALLBACKS.error(e.toString());}}private final AdListener bannerAdListener=new AdListener(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.click');");}@Override public void onAdClosed(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.close');");}@Override public void onAdFailedToLoad(@NonNull LoadAdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load');");isBannerLoad=false;isBannerShow=false;lock=true;PUBLIC_CALLBACKS.error(adError.toString());}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.impression');");}@Override public void onAdLoaded(){isBannerLoad=true;bannerAdImpression=1;isBannerPause=0;lock=false;if(bannerAutoShow){bannerViewLayout.addView(bannerView);isBannerPause=0;}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load');");bannerView.setOnPaidEventListener(bannerPaidAdListener);if(ResponseInfo){Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",Npa);bundleExtra.putInt("is_designed_for_families",SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",SetMaxAdContentRating);JSONObject result=new JSONObject();ResponseInfo responseInfo=bannerView.getResponseInfo();try{assert responseInfo!=null;result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getLoadedAdapter",responseInfo.getLoadedAdapterResponseInfo());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("bundleExtra",bundleExtra);PUBLIC_CALLBACKS.success(result);}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}}@Override public void onAdOpened(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.open');");}};private final OnPaidEventListener bannerPaidAdListener=new OnPaidEventListener(){@Override public void onPaidEvent(@NonNull AdValue adValue){long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=bannerView.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);isBannerLoad=false;PUBLIC_CALLBACKS.success(result);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.revenue');");}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}};public boolean isPrivacyOptionsRequired(){return consentInformation.getPrivacyOptionsRequirementStatus()==ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED;}private void consentInfoUpdate(){ConsentRequestParameters params=new ConsentRequestParameters .Builder().setTagForUnderAgeOfConsent(false).build();consentInformation=UserMessagingPlatform.getConsentInformation(mActivity);consentInformation.requestConsentInfoUpdate(mActivity,params,(ConsentInformation.OnConsentInfoUpdateSuccessListener)this::OptionsMenu,(ConsentInformation.OnConsentInfoUpdateFailureListener)requestConsentError ->{PUBLIC_CALLBACKS.error(requestConsentError.getMessage());});}private void OptionsMenu(){try{UserMessagingPlatform.loadAndShowConsentFormIfRequired(mActivity,(ConsentForm.OnConsentFormDismissedListener)loadAndShowError ->{if(loadAndShowError!=null){PUBLIC_CALLBACKS.error(loadAndShowError.getMessage());}if(isPrivacyOptionsRequired()){invalidateOptionsMenu();}});}catch(Exception e){throw new RuntimeException(e);}}private void invalidateOptionsMenu(){UserMessagingPlatform.showPrivacyOptionsForm(mActivity,formError ->{if(formError!=null){PUBLIC_CALLBACKS.error(formError.getMessage());}});}private void _appOpenAdLoadCallback(CallbackContext callbackContext){appOpenAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdDismissedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.dismissed');");View mainView=getView();if(mainView!=null){mainView.requestFocus();}}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.show');");callbackContext.error(adError.toString());appOpenAd=null;}@Override public void onAdShowedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.show');");}});}private void _interstitialAdLoadCallback(CallbackContext callbackContext){mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.click');");}@Override public void onAdDismissedFullScreenContent(){mInterstitialAd=null;isinterstitialload=false;View mainView=getView();if(mainView!=null){mainView.requestFocus();}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){mInterstitialAd=null;isinterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.impression');");}@Override public void onAdShowedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.show');");}});}private void _rewardedAdLoadCallback(CallbackContext callbackContext){rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.click');");}@Override public void onAdDismissedFullScreenContent(){if(isAdSkip!=2){rewardedAd=null;isrewardedload=false;View mainView=getView();if(mainView!=null){mainView.requestFocus();}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.ad.skip');");}rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){rewardedAd=null;isrewardedload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.impression');");}@Override public void onAdShowedFullScreenContent(){isAdSkip=1;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.show');");}});}private void _rewardedInterstitialAdLoadCallback(CallbackContext callbackContext){rewardedInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.click');");}@Override public void onAdDismissedFullScreenContent(){if(isAdSkip!=2){rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.ad.skip');");}rewardedInterstitialAd=null;isrewardedInterstitialload=false;View mainView=getView();if(mainView!=null){mainView.requestFocus();}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){rewardedInterstitialAd=null;isrewardedInterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.impression');");}@Override public void onAdShowedFullScreenContent(){isAdSkip=1;Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.showed');");}});}public void _globalSettings(){MobileAds.setAppMuted(this.SetAppMuted);MobileAds.setAppVolume(this.SetAppVolume);MobileAds.putPublisherFirstPartyIdEnabled(this.EnableSameAppKey);}public void _Targeting(){RequestConfiguration.Builder requestConfiguration=MobileAds.getRequestConfiguration().toBuilder();if(SetTagForChildDirectedTreatment==-1){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED);}else if(SetTagForChildDirectedTreatment==0){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE);}else if(SetTagForChildDirectedTreatment==1){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE);}else{requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED);}if(SetTagForUnderAgeOfConsent){requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE);}else{requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE);}if(Objects.equals(SetMaxAdContentRating,"")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED);}else if(Objects.equals(SetMaxAdContentRating,"T")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_T);}else if(Objects.equals(SetMaxAdContentRating,"PG")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_PG);}else if(Objects.equals(SetMaxAdContentRating,"MA")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_MA);}else if(Objects.equals(SetMaxAdContentRating,"G")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G);}else{requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED);}MobileAds.setRequestConfiguration(requestConfiguration.build());}private View getView(){if(View.class.isAssignableFrom(CordovaWebView.class)){return(View)cWebView;}return cordova.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);}@Override public void onPause(boolean multitasking){if(bannerView!=null){bannerView.pause();}super.onPause(multitasking);}@Override public void onResume(boolean multitasking){super.onResume(multitasking);if(bannerView!=null){bannerView.resume();}}@Override public void onDestroy(){if(bannerView!=null){bannerView.destroy();bannerView=null;}if(bannerViewLayout!=null){ViewGroup parentView=(ViewGroup)bannerViewLayout.getParent();if(parentView!=null){parentView.removeView(bannerViewLayout);}bannerViewLayout=null;}bannerAdImpression=0;super.onDestroy();}}
|
1
|
+
package emi.indo.cordova.plugin.admob;import android.annotation.SuppressLint;import android.app.Activity;import android.content.ContentResolver;import android.content.Context;import android.content.SharedPreferences;import android.content.res.Configuration;import android.os.Bundle;import android.provider.Settings;import android.util.Log;import android.view.View;import android.view.ViewGroup;import android.widget.RelativeLayout;import androidx.annotation.NonNull;import androidx.preference.PreferenceManager;import com.google.ads.mediation.admob.AdMobAdapter;import com.google.android.gms.ads.AdError;import com.google.android.gms.ads.AdListener;import com.google.android.gms.ads.AdRequest;import com.google.android.gms.ads.AdSize;import com.google.android.gms.ads.AdValue;import com.google.android.gms.ads.AdView;import com.google.android.gms.ads.FullScreenContentCallback;import com.google.android.gms.ads.LoadAdError;import com.google.android.gms.ads.MobileAds;import com.google.android.gms.ads.OnPaidEventListener;import com.google.android.gms.ads.RequestConfiguration;import com.google.android.gms.ads.ResponseInfo;import com.google.android.gms.ads.appopen.AppOpenAd;import com.google.android.gms.ads.initialization.AdapterStatus;import com.google.android.gms.ads.interstitial.InterstitialAd;import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;import com.google.android.gms.ads.rewarded.RewardedAd;import com.google.android.gms.ads.rewarded.RewardedAdLoadCallback;import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd;import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback;import com.google.android.ump.ConsentDebugSettings;import com.google.android.ump.ConsentForm;import com.google.android.ump.ConsentInformation;import com.google.android.ump.ConsentRequestParameters;import com.google.android.ump.UserMessagingPlatform;import org.apache.cordova.CallbackContext;import org.apache.cordova.CordovaInterface;import org.apache.cordova.CordovaPlugin;import org.apache.cordova.CordovaWebView;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.util.Map;import java.util.Objects;public class emiAdmobPlugin extends CordovaPlugin{private static final String TAG="emiAdmobPlugin";private CallbackContext PUBLIC_CALLBACKS=null;private InterstitialAd mInterstitialAd;private RewardedAd rewardedAd;private RewardedInterstitialAd rewardedInterstitialAd;private CordovaWebView cWebView;private boolean isAppOpenAdShow=false;static boolean isinterstitialload=false;static boolean isrewardedInterstitialload=false;static boolean isrewardedload=false;int isBannerPause=0;String Npa;String Position;String Size;int AdaptiveWidth=320;Boolean ResponseInfo=false;int bannerAdImpression=0;private int isAdSkip=0;int SetTagForChildDirectedTreatment=-1;Boolean SetTagForUnderAgeOfConsent=false;String SetMaxAdContentRating="G";String appOpenAdUnitId;String bannerAdUnitId;String interstitialAdUnitId;String rewardedInterstitialAdUnitId;String rewardedAdUnitId;boolean SetAppMuted=false;float SetAppVolume=1;boolean EnableSameAppKey=false;private ConsentInformation consentInformation;private RelativeLayout bannerViewLayout;private AdView bannerView;private boolean isBannerLoad=false;private boolean isBannerShow=false;Boolean bannerAutoShow=false;Boolean appOpenAutoShow=false;Boolean intAutoShow=false;Boolean rewardedAutoShow=false;Boolean rIntAutoShow=false;String Collapsible;Boolean isCollapsible=false;Boolean lock=true;Boolean setDebugGeography=false;protected Activity mActivity;protected Context mContext;private AppOpenAd appOpenAd;int orientation=0;private static final String LAST_ACCESS_SUFFIX="_last_access";private static final long EXPIRATION_TIME=(long)360 * 24 * 60 * 60 * 1000;private SharedPreferences mPreferences;public void initialize(CordovaInterface cordova,CordovaWebView webView){super.initialize(cordova,webView);cWebView=webView;mActivity=this.cordova.getActivity();mContext=mActivity.getApplicationContext();mPreferences=PreferenceManager.getDefaultSharedPreferences(mContext);int orientation=mActivity.getResources().getConfiguration().orientation;if(orientation==Configuration.ORIENTATION_PORTRAIT){this.orientation=0;}else{this.orientation=1;}}public boolean execute(String action,JSONArray args,final CallbackContext callbackContext){PUBLIC_CALLBACKS=callbackContext;switch(action){case "initialize":Log.d(TAG,"Google Mobile Ads SDK: "+MobileAds.getVersion());MobileAds.initialize(mActivity,initializationStatus ->{Map<String,AdapterStatus> statusMap=initializationStatus.getAdapterStatusMap();for(String adapterClass:statusMap.keySet()){AdapterStatus status=statusMap.get(adapterClass);if(status!=null){Log.d(TAG,String.format("Adapter name:%s,Description:%s,Latency:%d",adapterClass,status.getDescription(),status.getLatency()));}else{callbackContext.error(MobileAds.ERROR_DOMAIN);}}callbackContext.success("Google Mobile Ads SDK: "+MobileAds.getVersion());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.sdkInitialization');");});return true;case "targeting":cordova.getActivity().runOnUiThread(()->{final int childDirectedTreatment=args.optInt(0);final boolean underAgeOfConsent=args.optBoolean(1);final String contentRating=args.optString(2);try{this.SetTagForChildDirectedTreatment=childDirectedTreatment;this.SetTagForUnderAgeOfConsent=underAgeOfConsent;this.SetMaxAdContentRating=contentRating;_Targeting();}catch(Exception e){callbackContext.error(e.toString());}});return true;case "globalSettings":cordova.getActivity().runOnUiThread(()->{final boolean setAppMuted=args.optBoolean(0);final float setAppVolume=(float)args.optDouble(1);final boolean publisherFirstPartyIdEnabled=args.optBoolean(2);final String npa=args.optString(3);final boolean enableCollapsible=args.optBoolean(4);final boolean responseInfo=args.optBoolean(5);final boolean setDebugGeography=args.optBoolean(6);try{this.SetAppMuted=setAppMuted;this.SetAppVolume=setAppVolume;this.EnableSameAppKey=publisherFirstPartyIdEnabled;this.Npa=npa;this.isCollapsible=enableCollapsible;this.ResponseInfo=responseInfo;this.setDebugGeography=setDebugGeography;_globalSettings();}catch(Exception e){callbackContext.error(e.toString());}});return true;case "loadAppOpenAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final boolean autoShow=args.optBoolean(1);try{this.appOpenAdUnitId=adUnitId;this.appOpenAutoShow=autoShow;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();AppOpenAd.load(mActivity,this.appOpenAdUnitId,adRequest,new AppOpenAd.AppOpenAdLoadCallback(){@Override public void onAdLoaded(@NonNull AppOpenAd ad){appOpenAd=ad;isAppOpenAdShow=true;if(appOpenAutoShow){cordova.getActivity().runOnUiThread(()-> appOpenAd.show(mActivity));_appOpenAdLoadCallback(callbackContext);}appOpenAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=appOpenAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.revenue');");}catch(JSONException e){callbackContext.error(e.getMessage());}});cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.loaded');");if(ResponseInfo){JSONObject result=new JSONObject();ResponseInfo responseInfo=ad.getResponseInfo();try{result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("getMediationAdapterClassName",responseInfo.getMediationAdapterClassName());result.put("getBundleExtra",bundleExtra);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){isAppOpenAdShow=false;callbackContext.error(loadAdError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.loaded');");}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showAppOpenAd":if(isAppOpenAdShow){cordova.getActivity().runOnUiThread(()-> appOpenAd.show(mActivity));_appOpenAdLoadCallback(callbackContext);}else{callbackContext.error("The App Open Ad wasn't ready yet");}return true;case "loadInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final boolean autoShow=args.optBoolean(1);try{this.interstitialAdUnitId=adUnitId;this.intAutoShow=autoShow;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();InterstitialAd.load(mActivity,this.interstitialAdUnitId,adRequest,new InterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd){isinterstitialload=true;mInterstitialAd=interstitialAd;if(intAutoShow){cordova.getActivity().runOnUiThread(()-> mInterstitialAd.show(mActivity));_interstitialAdLoadCallback(callbackContext);}Log.i(TAG,"onAdLoaded");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.loaded');");if(ResponseInfo){JSONObject result=new JSONObject();ResponseInfo responseInfo=mInterstitialAd.getResponseInfo();try{result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("getMediationAdapterClassName",responseInfo.getMediationAdapterClassName());result.put("getBundleExtra",bundleExtra);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}}mInterstitialAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=mInterstitialAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.revenue');");});}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.load');");callbackContext.error(loadAdError.toString());}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showInterstitialAd":if(isinterstitialload){cordova.getActivity().runOnUiThread(()-> mInterstitialAd.show(mActivity));_interstitialAdLoadCallback(callbackContext);}else{callbackContext.error("The Interstitial ad wasn't ready yet");}return true;case "loadRewardedAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final boolean autoShow=args.optBoolean(1);try{this.rewardedAdUnitId=adUnitId;this.rewardedAutoShow=autoShow;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedAd.load(mActivity,this.rewardedAdUnitId,adRequest,new RewardedAdLoadCallback(){public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.load');");callbackContext.error(loadAdError.toString());}@Override public void onAdLoaded(@NonNull RewardedAd ad){rewardedAd=ad;isrewardedload=true;isAdSkip=0;if(rewardedAutoShow){isAdSkip=1;rewardedAd.show(mActivity,rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});_rewardedAdLoadCallback(callbackContext);}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.loaded');");if(ResponseInfo){JSONObject result=new JSONObject();ResponseInfo responseInfo=ad.getResponseInfo();try{result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("getMediationAdapterClassName",responseInfo.getMediationAdapterClassName());result.put("getBundleExtra",bundleExtra);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}}rewardedAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=rewardedAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.revenue');");});}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showRewardedAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedload){isAdSkip=1;rewardedAd.show(mActivity,rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.reward.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});_rewardedAdLoadCallback(callbackContext);}else{callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "loadRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final boolean autoShow=args.optBoolean(1);try{this.rewardedInterstitialAdUnitId=adUnitId;this.rIntAutoShow=autoShow;Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedInterstitialAd.load(mActivity,this.rewardedInterstitialAdUnitId,adRequest,new RewardedInterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull RewardedInterstitialAd ad){rewardedInterstitialAd=ad;isrewardedInterstitialload=true;isAdSkip=0;if(rIntAutoShow){isAdSkip=1;rewardedInterstitialAd.show(mActivity,rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});_rewardedInterstitialAdLoadCallback(callbackContext);}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.loaded');");if(ResponseInfo){JSONObject result=new JSONObject();ResponseInfo responseInfo=ad.getResponseInfo();try{result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("getMediationAdapterClassName",responseInfo.getMediationAdapterClassName());result.put("getBundleExtra",bundleExtra);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}}rewardedInterstitialAd.setOnPaidEventListener(adValue ->{long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=rewardedInterstitialAd.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);callbackContext.success(result);}catch(JSONException e){callbackContext.error(e.getMessage());}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.revenue');");});}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.load');");callbackContext.error(loadAdError.toString());}});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedInterstitialload){isAdSkip=1;rewardedInterstitialAd.show(mActivity,rewardItem ->{isAdSkip=2;int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.userEarnedReward');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{callbackContext.error("The rewarded ad wasn't ready yet");}_rewardedInterstitialAdLoadCallback(callbackContext);});return true;case "loadBannerAd":cordova.getActivity().runOnUiThread(()->{final String adUnitId=args.optString(0);final String position=args.optString(1);final String size=args.optString(2);final String collapsible=args.optString(3);final int adaptive_Width=args.optInt(4);final boolean autoShow=args.optBoolean(5);try{this.bannerAdUnitId=adUnitId;this.Position=position;this.Size=size;this.AdaptiveWidth=adaptive_Width;this.Collapsible=collapsible;this.bannerAutoShow=autoShow;if(lock){_loadBannerAd(adUnitId,position,size,collapsible,adaptive_Width);}}catch(Exception e){callbackContext.error(e.toString());}});return true;case "getConsentRequest":cordova.getActivity().runOnUiThread(()->{try{if(setDebugGeography){ConsentDebugSettings debugSettings=new ConsentDebugSettings.Builder(mActivity).setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA).addTestDeviceHashedId(getDeviceId()).build();ConsentRequestParameters params=new ConsentRequestParameters .Builder().setConsentDebugSettings(debugSettings).build();consentInformation=UserMessagingPlatform.getConsentInformation(cordova.getContext());consentInformation.requestConsentInfoUpdate(cordova.getActivity(),params,()->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update');");if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.NOT_REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.NOT_REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.not_required');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.OBTAINED){callbackContext.success(ConsentInformation.ConsentStatus.OBTAINED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.obtained');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.required');");if(consentInformation.isConsentFormAvailable()){UserMessagingPlatform.loadConsentForm(cordova.getContext(),consentForm -> consentForm.show(cordova.getActivity(),formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show');");callbackContext.error(String.valueOf(formError));}),formError -> callbackContext.error(formError.toString()));cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from');");}else{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.form.not.available');");}}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.UNKNOWN){callbackContext.success(ConsentInformation.ConsentStatus.UNKNOWN);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.unknown');");}},formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed');");callbackContext.error(formError.toString());});}else{ConsentRequestParameters params=new ConsentRequestParameters .Builder().setTagForUnderAgeOfConsent(this.SetTagForUnderAgeOfConsent).build();consentInformation=UserMessagingPlatform.getConsentInformation(cordova.getContext());consentInformation.requestConsentInfoUpdate(cordova.getActivity(),params,()->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update');");if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.NOT_REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.NOT_REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.not_required');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.OBTAINED){callbackContext.success(ConsentInformation.ConsentStatus.OBTAINED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.obtained');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.required');");if(consentInformation.isConsentFormAvailable()){UserMessagingPlatform.loadConsentForm(cordova.getContext(),consentForm -> consentForm.show(cordova.getActivity(),formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.show');");callbackContext.error(String.valueOf(formError));}),formError -> callbackContext.error(formError.getMessage()));cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.failed.load.from');");}else{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.form.not.available');");}}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.UNKNOWN){callbackContext.success(ConsentInformation.ConsentStatus.UNKNOWN);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.status.unknown');");}},formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed');");callbackContext.error(formError.getMessage());});}}catch(Exception e){callbackContext.error(e.toString());}});return true;case "showPrivacyOptionsForm":cordova.getActivity().runOnUiThread(()->{try{ConsentRequestParameters params=new ConsentRequestParameters .Builder().setTagForUnderAgeOfConsent(this.SetTagForUnderAgeOfConsent).build();consentInformation=UserMessagingPlatform.getConsentInformation(mContext);consentInformation.requestConsentInfoUpdate(mActivity,params,(ConsentInformation.OnConsentInfoUpdateSuccessListener)()->{int status=consentInformation.getConsentStatus();PUBLIC_CALLBACKS.success(status);UserMessagingPlatform.loadAndShowConsentFormIfRequired(mActivity,(ConsentForm.OnConsentFormDismissedListener)loadAndShowError ->{if(loadAndShowError!=null){PUBLIC_CALLBACKS.error(loadAndShowError.toString());}if(isPrivacyOptionsRequired()){UserMessagingPlatform.showPrivacyOptionsForm(mActivity,formError ->{if(formError!=null){PUBLIC_CALLBACKS.error(formError.toString());}});}});},(ConsentInformation.OnConsentInfoUpdateFailureListener)requestConsentError ->{PUBLIC_CALLBACKS.error(requestConsentError.toString());});}catch(Exception e){callbackContext.error(e.toString());}});return true;case "consentReset":cordova.getActivity().runOnUiThread(()->{try{consentInformation.reset();}catch(Exception e){callbackContext.error(e.toString());}});return true;case "getIabTfc":cordova.getActivity().runOnUiThread(()->{int gdprApplies=mPreferences.getInt("IABTCF_gdprApplies",0);String purposeConsents=mPreferences.getString("IABTCF_PurposeConsents","");String vendorConsents=mPreferences.getString("IABTCF_VendorConsents","");String consentString=mPreferences.getString("IABTCF_TCString","");JSONObject userInfoJson=new JSONObject();try{userInfoJson.put("IABTCF_gdprApplies",gdprApplies);userInfoJson.put("IABTCF_PurposeConsents",purposeConsents);userInfoJson.put("IABTCF_VendorConsents",vendorConsents);userInfoJson.put("IABTCF_TCString",consentString);SharedPreferences.Editor editor=mPreferences.edit();editor.putString("IABTCF_TCString",consentString);editor.putLong(LAST_ACCESS_SUFFIX,System.currentTimeMillis());editor.apply();final String key="IABTCF_TCString";getString(key);callbackContext.success(userInfoJson);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc');");}catch(Exception e){callbackContext.error(e.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.getIabTfc.error');");}});return true;case "showBannerAd":cordova.getActivity().runOnUiThread(()->{if(isBannerPause==0){if(isBannerLoad){try{bannerViewLayout.addView(bannerView);isBannerShow=true;}catch(Exception e){lock=true;callbackContext.error(e.toString());}}}else if(isBannerPause==1){try{bannerView.setVisibility(View.VISIBLE);bannerView.resume();}catch(Exception e){lock=true;callbackContext.error(e.toString());}}});return true;case "hideBannerAd":cordova.getActivity().runOnUiThread(()->{if(isBannerShow){try{bannerView.setVisibility(View.GONE);bannerView.pause();isBannerLoad=false;isBannerPause=1;}catch(Exception e){callbackContext.error(e.toString());}}});return true;case "removeBannerAd":cordova.getActivity().runOnUiThread(()->{if(bannerView==null)return;RelativeLayout bannerViewLayout=(RelativeLayout)bannerView.getParent();if(bannerViewLayout!=null){bannerViewLayout.removeView(bannerView);bannerView.destroy();bannerView=null;isBannerLoad=false;isBannerShow=false;isBannerPause=2;lock=true;bannerAdImpression=0;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.remove');");}});return true;}return false;}public String getDeviceId()throws NoSuchAlgorithmException{MessageDigest messageDigest=MessageDigest.getInstance("MD5");ContentResolver contentResolver=mContext.getContentResolver();@SuppressLint("HardwareIds")String androidId= Settings.Secure.getString(contentResolver,"android_id");messageDigest.update(androidId.getBytes());byte[]by=messageDigest.digest();StringBuilder sb=new StringBuilder();int n=by.length;for(byte b:by){StringBuilder emi=new StringBuilder(Integer.toHexString((int)(255&b)));while(emi.length()<2){emi.insert(0,"0");}sb.append(emi);}String result=sb.toString();return result.toUpperCase();}public void getString(String key){long lastAccessTime=mPreferences.getLong(key+LAST_ACCESS_SUFFIX,0);long currentTime=System.currentTimeMillis();if(currentTime - lastAccessTime>EXPIRATION_TIME){removeKey(key);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.TCString.expired');");}SharedPreferences.Editor editor=mPreferences.edit();editor.putLong(key+LAST_ACCESS_SUFFIX,currentTime);editor.apply();}private void removeKey(String key){SharedPreferences.Editor editor=mPreferences.edit();editor.remove(key);editor.remove(key+LAST_ACCESS_SUFFIX);editor.apply();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.TCString.remove');");}private void _loadBannerAd(String adUnitId,String position,String size,String collapsible,int adaptive_Width){try{if(bannerViewLayout==null){bannerViewLayout=new RelativeLayout(mActivity);RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);try{((ViewGroup)(((View)Objects.requireNonNull(webView.getClass().getMethod("getView").invoke(webView))).getParent())).addView(bannerViewLayout,params);}catch(Exception e){((ViewGroup)webView).addView(bannerViewLayout,params);}}bannerView=new AdView(mActivity);if(Objects.equals(size,"BANNER")){bannerView.setAdSize(AdSize.BANNER);}else if(Objects.equals(size,"LARGE_BANNER")){bannerView.setAdSize(AdSize.LARGE_BANNER);}else if(Objects.equals(size,"MEDIUM_RECTANGLE")){bannerView.setAdSize(AdSize.MEDIUM_RECTANGLE);}else if(Objects.equals(size,"FULL_BANNER")){bannerView.setAdSize(AdSize.FULL_BANNER);}else if(Objects.equals(size,"LEADERBOARD")){bannerView.setAdSize(AdSize.LEADERBOARD);}else if(Objects.equals(size,"FLUID")){bannerView.setAdSize(AdSize.FLUID);}else if(Objects.equals(size,"ANCHORED")){bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(mActivity,adaptive_Width));}else if(Objects.equals(size,"IN_LINE")){bannerView.setAdSize(AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(mActivity,adaptive_Width));}else if(Objects.equals(size,"FULL_WIDTH")){bannerView.setAdSize(AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(mActivity,AdSize.FULL_WIDTH));}else{bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(mActivity,AdSize.FULL_WIDTH));}bannerView.setAdUnitId(adUnitId);Bundle bundleExtra=new Bundle();if(isCollapsible){bundleExtra.putString("collapsible",collapsible);}bundleExtra.putString("npa",this.Npa);bundleExtra.putInt("is_designed_for_families",this.SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",this.SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",this.SetMaxAdContentRating);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();bannerView.loadAd(adRequest);bannerView.setAdListener(bannerAdListener);RelativeLayout.LayoutParams bannerParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);switch(position){case "top-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;case "top-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "left":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "center":bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "bottom-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "bottom-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;default:bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);break;}bannerView.setLayoutParams(bannerParams);bannerViewLayout.bringToFront();}catch(Exception e){PUBLIC_CALLBACKS.error(e.toString());}}private final AdListener bannerAdListener=new AdListener(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.click');");}@Override public void onAdClosed(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.close');");}@Override public void onAdFailedToLoad(@NonNull LoadAdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.failed.load');");isBannerLoad=false;isBannerShow=false;lock=true;PUBLIC_CALLBACKS.error(adError.toString());}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.impression');");}@Override public void onAdLoaded(){isBannerLoad=true;bannerAdImpression=1;isBannerPause=0;lock=false;if(bannerAutoShow){bannerViewLayout.addView(bannerView);isBannerPause=0;isBannerLoad=true;}bannerView.setOnPaidEventListener(bannerPaidAdListener);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.load');");if(ResponseInfo){Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",Npa);bundleExtra.putInt("is_designed_for_families",SetTagForChildDirectedTreatment);bundleExtra.putBoolean("under_age_of_consent",SetTagForUnderAgeOfConsent);bundleExtra.putString("max_ad_content_rating",SetMaxAdContentRating);JSONObject result=new JSONObject();ResponseInfo responseInfo=bannerView.getResponseInfo();try{assert responseInfo!=null;result.put("getResponseId",responseInfo.getResponseId());result.put("getAdapterResponses",responseInfo.getAdapterResponses());result.put("getResponseExtras",responseInfo.getResponseExtras());result.put("getMediationAdapterClassName",responseInfo.getMediationAdapterClassName());result.put("getBundleExtra",bundleExtra);PUBLIC_CALLBACKS.success(result);}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}}@Override public void onAdOpened(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.open');");}};private final OnPaidEventListener bannerPaidAdListener=new OnPaidEventListener(){@Override public void onPaidEvent(@NonNull AdValue adValue){long valueMicros=adValue.getValueMicros();String currencyCode=adValue.getCurrencyCode();int precision=adValue.getPrecisionType();String adUnitId=bannerView.getAdUnitId();JSONObject result=new JSONObject();try{result.put("micros",valueMicros);result.put("currency",currencyCode);result.put("precision",precision);result.put("adUnitId",adUnitId);isBannerLoad=false;PUBLIC_CALLBACKS.success(result);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.banner.revenue');");}catch(JSONException e){PUBLIC_CALLBACKS.error(e.getMessage());}}};public boolean isPrivacyOptionsRequired(){return consentInformation.getPrivacyOptionsRequirementStatus()==ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED;}private void _appOpenAdLoadCallback(CallbackContext callbackContext){appOpenAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdDismissedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.dismissed');");View mainView=getView();if(mainView!=null){mainView.requestFocus();}}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.failed.show');");callbackContext.error(adError.toString());appOpenAd=null;}@Override public void onAdShowedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.appOpenAd.show');");}});}private void _interstitialAdLoadCallback(CallbackContext callbackContext){mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.click');");}@Override public void onAdDismissedFullScreenContent(){mInterstitialAd=null;isinterstitialload=false;View mainView=getView();if(mainView!=null){mainView.requestFocus();}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){mInterstitialAd=null;isinterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.impression');");}@Override public void onAdShowedFullScreenContent(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.interstitial.show');");}});}private void _rewardedAdLoadCallback(CallbackContext callbackContext){rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.click');");}@Override public void onAdDismissedFullScreenContent(){if(isAdSkip!=2){rewardedAd=null;isrewardedload=false;View mainView=getView();if(mainView!=null){mainView.requestFocus();}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.ad.skip');");}rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){rewardedAd=null;isrewardedload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.impression');");}@Override public void onAdShowedFullScreenContent(){isAdSkip=1;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.show');");}});}private void _rewardedInterstitialAdLoadCallback(CallbackContext callbackContext){rewardedInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.click');");}@Override public void onAdDismissedFullScreenContent(){if(isAdSkip!=2){rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.ad.skip');");}rewardedInterstitialAd=null;isrewardedInterstitialload=false;View mainView=getView();if(mainView!=null){mainView.requestFocus();}cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.dismissed');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){rewardedInterstitialAd=null;isrewardedInterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.failed.show');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.impression');");}@Override public void onAdShowedFullScreenContent(){isAdSkip=1;Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInt.showed');");}});}public void _globalSettings(){MobileAds.setAppMuted(this.SetAppMuted);MobileAds.setAppVolume(this.SetAppVolume);MobileAds.putPublisherFirstPartyIdEnabled(this.EnableSameAppKey);}public void _Targeting(){RequestConfiguration.Builder requestConfiguration=MobileAds.getRequestConfiguration().toBuilder();if(SetTagForChildDirectedTreatment==-1){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED);}else if(SetTagForChildDirectedTreatment==0){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE);}else if(SetTagForChildDirectedTreatment==1){requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE);}else{requestConfiguration.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED);}if(SetTagForUnderAgeOfConsent){requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE);}else{requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE);}if(Objects.equals(SetMaxAdContentRating,"")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED);}else if(Objects.equals(SetMaxAdContentRating,"T")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_T);}else if(Objects.equals(SetMaxAdContentRating,"PG")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_PG);}else if(Objects.equals(SetMaxAdContentRating,"MA")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_MA);}else if(Objects.equals(SetMaxAdContentRating,"G")){requestConfiguration.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G);}else{requestConfiguration.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED);}MobileAds.setRequestConfiguration(requestConfiguration.build());}private View getView(){if(View.class.isAssignableFrom(CordovaWebView.class)){return(View)cWebView;}return cordova.getActivity().getWindow().getDecorView().findViewById(android.R.id.content);}@Override public void onPause(boolean multitasking){if(bannerView!=null){bannerView.pause();}super.onPause(multitasking);}@Override public void onResume(boolean multitasking){super.onResume(multitasking);if(bannerView!=null){bannerView.resume();}}@Override public void onDestroy(){if(bannerView!=null){bannerView.destroy();bannerView=null;}if(bannerViewLayout!=null){ViewGroup parentView=(ViewGroup)bannerViewLayout.getParent();if(parentView!=null){parentView.removeView(bannerViewLayout);}bannerViewLayout=null;}bannerAdImpression=0;super.onDestroy();}}
|
package/www/emiAdmobPlugin.js
CHANGED
@@ -3,14 +3,14 @@ var exec = require('cordova/exec');
|
|
3
3
|
exports.initialize = function (success, error) {
|
4
4
|
exec(success, error, 'emiAdmobPlugin', 'initialize', []);
|
5
5
|
};
|
6
|
-
exports.loadAppOpenAd = function (arg0,
|
7
|
-
exec(success, error, 'emiAdmobPlugin', 'loadAppOpenAd', arg0
|
6
|
+
exports.loadAppOpenAd = function (arg0, success, error) {
|
7
|
+
exec(success, error, 'emiAdmobPlugin', 'loadAppOpenAd', arg0);
|
8
8
|
};
|
9
9
|
exports.showAppOpenAd = function (success, error) {
|
10
10
|
exec(success, error, 'emiAdmobPlugin', 'showAppOpenAd', []);
|
11
11
|
};
|
12
|
-
exports.loadBannerAd = function (arg0,
|
13
|
-
exec(success, error, 'emiAdmobPlugin', 'loadBannerAd', arg0
|
12
|
+
exports.loadBannerAd = function (arg0, success, error) {
|
13
|
+
exec(success, error, 'emiAdmobPlugin', 'loadBannerAd', arg0);
|
14
14
|
};
|
15
15
|
exports.showBannerAd = function (success, error) {
|
16
16
|
exec(success, error, 'emiAdmobPlugin', 'showBannerAd', []);
|
@@ -21,20 +21,20 @@ exports.hideBannerAd = function (success, error) {
|
|
21
21
|
exports.removeBannerAd = function (arg0, success, error) {
|
22
22
|
exec(success, error, 'emiAdmobPlugin', 'removeBannerAd', [arg0]);
|
23
23
|
};
|
24
|
-
exports.loadInterstitialAd = function (arg0,
|
25
|
-
exec(success, error, 'emiAdmobPlugin', 'loadInterstitialAd', arg0
|
24
|
+
exports.loadInterstitialAd = function (arg0, success, error) {
|
25
|
+
exec(success, error, 'emiAdmobPlugin', 'loadInterstitialAd', arg0);
|
26
26
|
};
|
27
27
|
exports.showInterstitialAd = function (success, error) {
|
28
28
|
exec(success, error, 'emiAdmobPlugin', 'showInterstitialAd', []);
|
29
29
|
};
|
30
|
-
exports.loadRewardedAd = function (arg0,
|
31
|
-
exec(success, error, 'emiAdmobPlugin', 'loadRewardedAd', arg0
|
30
|
+
exports.loadRewardedAd = function (arg0, success, error) {
|
31
|
+
exec(success, error, 'emiAdmobPlugin', 'loadRewardedAd', arg0);
|
32
32
|
};
|
33
33
|
exports.showRewardedAd = function (success, error) {
|
34
34
|
exec(success, error, 'emiAdmobPlugin', 'showRewardedAd', []);
|
35
35
|
};
|
36
|
-
exports.loadRewardedInterstitialAd = function (arg0,
|
37
|
-
exec(success, error, 'emiAdmobPlugin', 'loadRewardedInterstitialAd', arg0
|
36
|
+
exports.loadRewardedInterstitialAd = function (arg0, success, error) {
|
37
|
+
exec(success, error, 'emiAdmobPlugin', 'loadRewardedInterstitialAd', arg0);
|
38
38
|
};
|
39
39
|
exports.showRewardedInterstitialAd = function (success, error) {
|
40
40
|
exec(success, error, 'emiAdmobPlugin', 'showRewardedInterstitialAd', []);
|
@@ -48,8 +48,8 @@ exports.getConsentRequest = function (success, error) {
|
|
48
48
|
exports.consentReset = function (success, error) {
|
49
49
|
exec(success, error, 'emiAdmobPlugin', 'consentReset', []);
|
50
50
|
};
|
51
|
-
exports.targeting = function (arg0,
|
52
|
-
exec(success, error, 'emiAdmobPlugin', 'targeting', arg0
|
51
|
+
exports.targeting = function (arg0, success, error) {
|
52
|
+
exec(success, error, 'emiAdmobPlugin', 'targeting', arg0);
|
53
53
|
};
|
54
54
|
exports.getIabTfc = function (success, error) {
|
55
55
|
exec(success, error, 'emiAdmobPlugin', 'getIabTfc', []);
|
@@ -57,7 +57,6 @@ exports.getIabTfc = function (success, error) {
|
|
57
57
|
exports.showPrivacyOptionsForm = function (success, error) {
|
58
58
|
exec(success, error, 'emiAdmobPlugin', 'showPrivacyOptionsForm', []);
|
59
59
|
};
|
60
|
-
exports.globalSettings = function (arg0,
|
61
|
-
exec(success, error, 'emiAdmobPlugin', 'globalSettings', arg0
|
62
|
-
};
|
63
|
-
|
60
|
+
exports.globalSettings = function (arg0, success, error) {
|
61
|
+
exec(success, error, 'emiAdmobPlugin', 'globalSettings', arg0);
|
62
|
+
};
|