emi-indo-cordova-plugin-admob 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,14 @@
1
1
  # emi-indo-cordova-plugin-admob
2
- Cordova Plugin Admob Android
2
+ Cordova Plugin Admob Android and IOS
3
+
4
+ ### Mobile Ads SDK (Android: 22.0.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
5
+
6
+ ### Mobile Ads SDK (IOS: 10.3.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
7
+
8
+ ### [Documentation for IOS](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/3)
9
+
10
+ -
3
11
 
4
- ### Mobile Ads SDK (Android: 22.0.0)
5
- [Release Notes:](https://developers.google.com/admob/android/rel-notes)
6
12
 
7
13
  > __Warning__
8
14
  > Updating the Mobile Ads SDK version may cause some code to malfunction, as the latest version usually deprecates some older code, [scrrenshot](https://drive.google.com/file/d/1UKaEjdmGRXgdZ2DKfOne8BSq13IUY14_/view) Current plugin code SDK 22.0.0
@@ -36,11 +42,16 @@ https://user-images.githubusercontent.com/78555833/228323239-e9e18e74-b814-4ca8-
36
42
  - Interstitial Ads
37
43
  - Rewarded Ads
38
44
  - Rewarded interstitial Ads
45
+ - [Consent](https://github.com/EMI-INDO/emi-indo-cordova-plugin-consent)
46
+ - Mediation
39
47
 
40
48
  ## Coming soon
41
49
  - App Open Ads
42
- - User Consent
43
- - Mediation ( In the process )
50
+ - User Consent ( Finished ) [emi-indo-cordova-plugin-consent](https://github.com/EMI-INDO/emi-indo-cordova-plugin-consent)
51
+ - Mediation ( Finished )
52
+
53
+
54
+
44
55
 
45
56
 
46
57
  ## Installation
@@ -128,6 +139,7 @@ alert("on Sdk Initialization Complete");
128
139
  - position | index 1
129
140
  - size | index 2
130
141
  - adaptiveWidth | index 3
142
+ - npa | index 4
131
143
 
132
144
 
133
145
  ```sh
@@ -144,6 +156,7 @@ let showBannerAdaptive = () => {
144
156
  position = "bottom-center",
145
157
  size = "Inline_adaptive", // | Inline_adaptive | Anchored_adaptive
146
158
  adaptiveWidth = 320,
159
+ npa = "1", // String | 0 | 1
147
160
 
148
161
  (seccess) => { console.log("success") },
149
162
  (error) => { alert(error)
@@ -160,6 +173,7 @@ let showBannerNotAdaptive = () => {
160
173
  bannerAdUnitId = "ca-app-pub-3940256099942544/6300978111",
161
174
  position = "bottom-center",
162
175
  size = "BANNER",
176
+ npa = "1", // String | 0 | 1
163
177
 
164
178
  (seccess) => { console.log("success") },
165
179
  (error) => { alert(error)
@@ -187,6 +201,7 @@ let removeBannerAd = () => {
187
201
  ### Variable name and index (final) cannot be changed.
188
202
  - interstitialAdAdUnitId | index 0
189
203
  - responseInfo | index 1
204
+ - npa | index 2
190
205
 
191
206
  ```sh
192
207
  // Load Interstitial Ad
@@ -195,6 +210,7 @@ let loadInterstitialAd = () => {
195
210
  cordova.plugins.emiAdmobPlugin.loadInterstitialAd(
196
211
  interstitialAdAdUnitId = "ca-app-pub-3940256099942544/1033173712",
197
212
  responseInfo = true, // boolean (debugging)
213
+ npa = "1", // String | 0 | 1
198
214
 
199
215
  (info) => { alert(info) },
200
216
  (error) => { alert(error)
@@ -224,6 +240,7 @@ let showInterstitialAd = () => {
224
240
  ### Variable name and index (final) cannot be changed.
225
241
  - rewardedAdAdUnitId | index 0
226
242
  - responseInfo | index 1
243
+ - npa | index 2
227
244
 
228
245
  ```sh
229
246
 
@@ -233,6 +250,7 @@ let loadRewardedAd = () => {
233
250
  cordova.plugins.emiAdmobPlugin.loadRewardedAd(
234
251
  rewardedAdAdUnitId = "ca-app-pub-3940256099942544/5224354917",
235
252
  responseInfo = true, // boolean (debugging)
253
+ npa = "1", // String | 0 | 1
236
254
 
237
255
 
238
256
  (info) => { alert(info) },
@@ -263,6 +281,7 @@ let showRewardedAd = () => {
263
281
  ### Variable name and index (final) cannot be changed.
264
282
  - rewardedInterstitialAdUnitId | index 0
265
283
  - responseInfo | index 1
284
+ - npa | index 2
266
285
 
267
286
  ```sh
268
287
 
@@ -272,6 +291,7 @@ let loadRewardedInterstitialAd = () => {
272
291
  cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd(
273
292
  rewardedInterstitialAdUnitId = "ca-app-pub-3940256099942544/5354046379",
274
293
  responseInfo = true, // boolean (debugging)
294
+ npa = "1", // String | 0 | 1
275
295
 
276
296
  (info) => { alert(info) },
277
297
  (error) => { alert(error)
@@ -326,8 +346,7 @@ alert("on.banner Ad Loaded");
326
346
  - right
327
347
  - bottom-center
328
348
  - bottom-right
329
- - adaptiveWidth = number
330
- > default: 320
349
+
331
350
 
332
351
 
333
352
  ### size
@@ -338,10 +357,13 @@ alert("on.banner Ad Loaded");
338
357
  - MEDIUM_RECTANGLE
339
358
  - FULL_BANNER
340
359
  - LEADERBOARD
360
+ - adaptiveWidth = number
341
361
  - Smart Banners = DEPRECATED
342
362
  - default: Anchored_adaptive
343
363
 
344
364
 
365
+
366
+
345
367
  ### Event Load a Show
346
368
 
347
369
  - on.bannerAdClicked
@@ -387,6 +409,7 @@ alert("on.banner Ad Loaded");
387
409
  - on.rewardedAdFailedToShowFullScreenContent
388
410
  - on.rewardedAdImpression
389
411
  - on.rewardedAdShowedFullScreenContent
412
+ - on.rewarded.rewarded
390
413
 
391
414
 
392
415
 
@@ -405,6 +428,10 @@ alert("on.banner Ad Loaded");
405
428
  - on.rewardedInterstitialAdFailedToShowFullScreenContent
406
429
  - on.rewardedInterstitialAdImpression
407
430
  - on.rewardedInterstitialAdShowedFullScreenContent
431
+ - on.rewardedInterstitial.rewarded
432
+
433
+
434
+
408
435
 
409
436
 
410
437
  # Admob Mediation
@@ -519,16 +546,22 @@ cordova plugin add emi-indo-cordova-plugin-mediation-meta --variable META_ADAPTE
519
546
  - ================================
520
547
 
521
548
 
522
-
549
+ emi-indo-cordova-plugin-admob@0.0.5
523
550
 
524
551
 
525
552
  > - ## Note Release
526
- [emi-indo-cordova-plugin-admob@0.0.4](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/%400.0.4)
553
+ - [emi-indo-cordova-plugin-admob@0.0.4](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/%400.0.4)
554
+
555
+ - [emi-indo-cordova-plugin-admob@0.0.5](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/v0.0.5)
556
+
557
+ <img src="https://user-images.githubusercontent.com/78555833/231241800-8834ca2a-fa95-4cc2-91ca-1478c6b3c1ef.jpg" width="250">
527
558
 
559
+ - [emi-indo-cordova-plugin-admob@0.0.6](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/v0.0.6)
528
560
 
529
561
 
530
562
  ### Platform Support
531
563
  - Android
564
+ - IOS
532
565
 
533
566
 
534
567
  ## 💰Sponsor this project
@@ -0,0 +1,115 @@
1
+ <html>
2
+ <head>
3
+ <script type="text/javascript" src="cordova.js"></script>
4
+ </head>
5
+ <body>
6
+
7
+ <script>
8
+
9
+ // Installation
10
+
11
+ // cordova plugin add emi-indo-cordova-plugin-consent
12
+ // cordova plugin add emi-indo-cordova-plugin-admob
13
+
14
+
15
+ let _getConsentRequest = () => {
16
+ cordova.plugins.emiAdmobPlugin.getConsentRequest(
17
+ setTagForUnderAgeOfConsent = false, // boolean
18
+
19
+ (status) => { alert(status) }, // check event code
20
+ (error) => { alert(error)
21
+
22
+ });
23
+ }
24
+
25
+ // call _getConsentRequest();
26
+
27
+
28
+
29
+ let _consentReset = () => {
30
+ cordova.plugins.emiAdmobPlugin.consentReset();
31
+ }
32
+
33
+ // call _consentReset();
34
+
35
+
36
+
37
+
38
+ document.addEventListener("deviceready", function(){
39
+
40
+
41
+
42
+
43
+ document.addEventListener('onConsentInfoUpdateSuccess', () => {
44
+
45
+ alert("on Consent Info Update Success");
46
+
47
+ });
48
+
49
+ document.addEventListener('onConsentInfoUpdateFailure', () => {
50
+
51
+ alert("on Consen Info Update Failure");
52
+
53
+ });
54
+
55
+ ////////////////////////////////////////////////
56
+
57
+ // https://developers.google.com/admob/android/privacy/api/reference/com/google/android/ump/ConsentInformation.ConsentStatus
58
+
59
+ document.addEventListener('on.ConsentStatus.NOT_REQUIRED', () => {
60
+ // Constant Value: 1
61
+ alert("User consent not required.");
62
+
63
+ });
64
+
65
+ document.addEventListener('on.ConsentStatus.OBTAINED', () => {
66
+ // Constant Value: 3
67
+ alert("User consent obtained. Personalized vs non-personalized undefined.");
68
+
69
+ });
70
+
71
+ document.addEventListener('on.ConsentStatus.REQUIRED', () => {
72
+ // Constant Value: 2
73
+ // is Consent Form Available = the code auto, load Consent Form and consent Form show.
74
+ alert("User consent required but not yet obtained.");
75
+
76
+ });
77
+
78
+ document.addEventListener('on.ConsentStatus.UNKNOWN', () => {
79
+ //Constant Value: 0
80
+ alert("Consent status is unknown.");
81
+
82
+ });
83
+
84
+
85
+ ////////////////////////////////////////////////////////////
86
+
87
+ document.addEventListener('on.loadConsentFormError', () => {
88
+
89
+ alert("on load Consent Form Error");
90
+
91
+ });
92
+
93
+ document.addEventListener('on.ConsentFormNotAvailable', () => {
94
+
95
+ alert("on Consent Form Not Available");
96
+
97
+ });
98
+
99
+
100
+
101
+
102
+ }, false);
103
+ </script>
104
+
105
+
106
+
107
+ <p> <button onclick="_getConsentRequest();">get Consent Request</button></p>
108
+
109
+ <p> <button onclick="_consentReset();">Consent reset</button></p>
110
+
111
+
112
+
113
+
114
+ </body>
115
+ </html>
@@ -20,6 +20,7 @@ let showBannerAdaptive = () => {
20
20
  position = "bottom-center",
21
21
  size = "Inline_adaptive", // | Inline_adaptive | Anchored_adaptive
22
22
  adaptiveWidth = 320,
23
+ npa = "1", // String | 0 | 1
23
24
 
24
25
  (seccess) => { console.log("success") },
25
26
  (error) => { alert(error)
@@ -34,6 +35,7 @@ let showBannerNotAdaptive = () => {
34
35
  bannerAdUnitId = "ca-app-pub-3940256099942544/6300978111",
35
36
  position = "bottom-center",
36
37
  size = "BANNER",
38
+ npa = "1", // String | 0 | 1
37
39
 
38
40
  (seccess) => { console.log("success") },
39
41
  (error) => { alert(error)
@@ -54,6 +56,7 @@ let loadInterstitialAd = () => {
54
56
  cordova.plugins.emiAdmobPlugin.loadInterstitialAd(
55
57
  interstitialAdAdUnitId = "ca-app-pub-3940256099942544/1033173712",
56
58
  responseInfo = true, // boolean
59
+ npa = "1", // String | 0 | 1
57
60
 
58
61
  (info) => { alert(info) },
59
62
  (error) => { alert(error)
@@ -73,6 +76,7 @@ let loadRewardedInterstitialAd = () => {
73
76
  cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd(
74
77
  rewardedInterstitialAdUnitId = "ca-app-pub-3940256099942544/5354046379",
75
78
  responseInfo = true, // boolean
79
+ npa = "1", // String | 0 | 1
76
80
 
77
81
  (info) => { alert(info) },
78
82
  (error) => { alert(error)
@@ -93,6 +97,7 @@ let loadRewardedAd = () => {
93
97
  cordova.plugins.emiAdmobPlugin.loadRewardedAd(
94
98
  rewardedAdAdUnitId = "ca-app-pub-3940256099942544/5224354917",
95
99
  responseInfo = true, // boolean
100
+ npa = "1", // String | 0 | 1
96
101
 
97
102
 
98
103
  (info) => { alert(info) },
@@ -171,6 +176,7 @@ on.rewardedInterstitialAdDismissedFullScreenContent
171
176
  on.rewardedInterstitialAdFailedToShowFullScreenContent
172
177
  on.rewardedInterstitialAdImpression
173
178
  on.rewardedInterstitialAdShowedFullScreenContent
179
+ on.rewardedInterstitial.rewarded
174
180
  */
175
181
 
176
182
  document.addEventListener('on.RewardedInterstitialAdLoaded', () => {
@@ -190,6 +196,7 @@ on.rewardedAdDismissedFullScreenContent
190
196
  on.rewardedAdFailedToShowFullScreenContent
191
197
  on.rewardedAdImpression
192
198
  on.rewardedAdShowedFullScreenContent
199
+ on.rewarded.rewarded
193
200
  */
194
201
 
195
202
  document.addEventListener('on.RewardedAdLoaded', () => {
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Cordova Plugin Admob Android",
5
5
  "cordova": {
6
6
  "id": "emi-indo-cordova-plugin-admob",
7
7
  "platforms": [
8
- "android"
8
+ "android",
9
+ "ios"
9
10
  ]
10
11
  },
11
12
  "keywords": [
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="0.0.5">
3
+ id="emi-indo-cordova-plugin-admob" version="0.0.7">
4
4
 
5
5
  <name>emiAdmobPlugin</name>
6
6
  <description>Cordova Plugin Admob Android</description>
@@ -29,6 +29,8 @@
29
29
  <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:excludeFromRecents="true" android:name="com.google.android.gms.ads.AdActivity" android:noHistory="true" />
30
30
  <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="$APP_ID_ANDROID" />
31
31
  <meta-data android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT" android:value="true"/>
32
+ <meta-data android:name="com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION" android:value="true"/>
33
+ <meta-data android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING" android:value="true"/>
32
34
  </config-file>
33
35
 
34
36
  <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
@@ -43,4 +45,237 @@
43
45
  <source-file src="src/android/emiAdmobPlugin.java" target-dir="src/emi/indo/cordova/plugin/admob"/>
44
46
 
45
47
  </platform>
48
+
49
+
50
+ <platform name="ios">
51
+
52
+ <config-file target="config.xml" parent="/*">
53
+ <feature name="emiAdmobPlugin">
54
+ <param name="ios-package" value="emiAdmobPlugin"/>
55
+ </feature>
56
+ </config-file>
57
+
58
+ <source-file src="src/ios/emiAdmobPlugin.swift" />
59
+
60
+ <preference name="APP_ID_IOS" default="ca-app-pub-3940256099942544~1458002511" />
61
+
62
+ <config-file target="*-Info.plist" parent="GADApplicationIdentifier">
63
+ <string>$APP_ID_IOS</string>
64
+ </config-file>
65
+
66
+ <config-file target="*-Info.plist" parent="SKAdNetworkItems">
67
+ <array>
68
+ <dict>
69
+ <key>SKAdNetworkIdentifier</key>
70
+ <string>cstr6suwn9.skadnetwork</string>
71
+ </dict>
72
+ <dict>
73
+ <key>SKAdNetworkIdentifier</key>
74
+ <string>4fzdc2evr5.skadnetwork</string>
75
+ </dict>
76
+ <dict>
77
+ <key>SKAdNetworkIdentifier</key>
78
+ <string>4pfyvq9l8r.skadnetwork</string>
79
+ </dict>
80
+ <dict>
81
+ <key>SKAdNetworkIdentifier</key>
82
+ <string>2fnua5tdw4.skadnetwork</string>
83
+ </dict>
84
+ <dict>
85
+ <key>SKAdNetworkIdentifier</key>
86
+ <string>ydx93a7ass.skadnetwork</string>
87
+ </dict>
88
+ <dict>
89
+ <key>SKAdNetworkIdentifier</key>
90
+ <string>5a6flpkh64.skadnetwork</string>
91
+ </dict>
92
+ <dict>
93
+ <key>SKAdNetworkIdentifier</key>
94
+ <string>p78axxw29g.skadnetwork</string>
95
+ </dict>
96
+ <dict>
97
+ <key>SKAdNetworkIdentifier</key>
98
+ <string>v72qych5uu.skadnetwork</string>
99
+ </dict>
100
+ <dict>
101
+ <key>SKAdNetworkIdentifier</key>
102
+ <string>ludvb6z3bs.skadnetwork</string>
103
+ </dict>
104
+ <dict>
105
+ <key>SKAdNetworkIdentifier</key>
106
+ <string>cp8zw746q7.skadnetwork</string>
107
+ </dict>
108
+ <dict>
109
+ <key>SKAdNetworkIdentifier</key>
110
+ <string>c6k4g5qg8m.skadnetwork</string>
111
+ </dict>
112
+ <dict>
113
+ <key>SKAdNetworkIdentifier</key>
114
+ <string>s39g8k73mm.skadnetwork</string>
115
+ </dict>
116
+ <dict>
117
+ <key>SKAdNetworkIdentifier</key>
118
+ <string>3qy4746246.skadnetwork</string>
119
+ </dict>
120
+ <dict>
121
+ <key>SKAdNetworkIdentifier</key>
122
+ <string>3sh42y64q3.skadnetwork</string>
123
+ </dict>
124
+ <dict>
125
+ <key>SKAdNetworkIdentifier</key>
126
+ <string>f38h382jlk.skadnetwork</string>
127
+ </dict>
128
+ <dict>
129
+ <key>SKAdNetworkIdentifier</key>
130
+ <string>hs6bdukanm.skadnetwork</string>
131
+ </dict>
132
+ <dict>
133
+ <key>SKAdNetworkIdentifier</key>
134
+ <string>prcb7njmu6.skadnetwork</string>
135
+ </dict>
136
+ <dict>
137
+ <key>SKAdNetworkIdentifier</key>
138
+ <string>v4nxqhlyqp.skadnetwork</string>
139
+ </dict>
140
+ <dict>
141
+ <key>SKAdNetworkIdentifier</key>
142
+ <string>wzmmz9fp6w.skadnetwork</string>
143
+ </dict>
144
+ <dict>
145
+ <key>SKAdNetworkIdentifier</key>
146
+ <string>yclnxrl5pm.skadnetwork</string>
147
+ </dict>
148
+ <dict>
149
+ <key>SKAdNetworkIdentifier</key>
150
+ <string>t38b2kh725.skadnetwork</string>
151
+ </dict>
152
+ <dict>
153
+ <key>SKAdNetworkIdentifier</key>
154
+ <string>7ug5zh24hu.skadnetwork</string>
155
+ </dict>
156
+ <dict>
157
+ <key>SKAdNetworkIdentifier</key>
158
+ <string>9rd848q2bz.skadnetwork</string>
159
+ </dict>
160
+ <dict>
161
+ <key>SKAdNetworkIdentifier</key>
162
+ <string>y5ghdn5j9k.skadnetwork</string>
163
+ </dict>
164
+ <dict>
165
+ <key>SKAdNetworkIdentifier</key>
166
+ <string>n6fk4nfna4.skadnetwork</string>
167
+ </dict>
168
+ <dict>
169
+ <key>SKAdNetworkIdentifier</key>
170
+ <string>v9wttpbfk9.skadnetwork</string>
171
+ </dict>
172
+ <dict>
173
+ <key>SKAdNetworkIdentifier</key>
174
+ <string>n38lu8286q.skadnetwork</string>
175
+ </dict>
176
+ <dict>
177
+ <key>SKAdNetworkIdentifier</key>
178
+ <string>47vhws6wlr.skadnetwork</string>
179
+ </dict>
180
+ <dict>
181
+ <key>SKAdNetworkIdentifier</key>
182
+ <string>kbd757ywx3.skadnetwork</string>
183
+ </dict>
184
+ <dict>
185
+ <key>SKAdNetworkIdentifier</key>
186
+ <string>9t245vhmpl.skadnetwork</string>
187
+ </dict>
188
+ <dict>
189
+ <key>SKAdNetworkIdentifier</key>
190
+ <string>a2p9lx4jpn.skadnetwork</string>
191
+ </dict>
192
+ <dict>
193
+ <key>SKAdNetworkIdentifier</key>
194
+ <string>22mmun2rn5.skadnetwork</string>
195
+ </dict>
196
+ <dict>
197
+ <key>SKAdNetworkIdentifier</key>
198
+ <string>4468km3ulz.skadnetwork</string>
199
+ </dict>
200
+ <dict>
201
+ <key>SKAdNetworkIdentifier</key>
202
+ <string>2u9pt9hc89.skadnetwork</string>
203
+ </dict>
204
+ <dict>
205
+ <key>SKAdNetworkIdentifier</key>
206
+ <string>8s468mfl3y.skadnetwork</string>
207
+ </dict>
208
+ <dict>
209
+ <key>SKAdNetworkIdentifier</key>
210
+ <string>av6w8kgt66.skadnetwork</string>
211
+ </dict>
212
+ <dict>
213
+ <key>SKAdNetworkIdentifier</key>
214
+ <string>klf5c3l5u5.skadnetwork</string>
215
+ </dict>
216
+ <dict>
217
+ <key>SKAdNetworkIdentifier</key>
218
+ <string>ppxm28t8ap.skadnetwork</string>
219
+ </dict>
220
+ <dict>
221
+ <key>SKAdNetworkIdentifier</key>
222
+ <string>424m5254lk.skadnetwork</string>
223
+ </dict>
224
+ <dict>
225
+ <key>SKAdNetworkIdentifier</key>
226
+ <string>ecpz2srf59.skadnetwork</string>
227
+ </dict>
228
+ <dict>
229
+ <key>SKAdNetworkIdentifier</key>
230
+ <string>uw77j35x4d.skadnetwork</string>
231
+ </dict>
232
+ <dict>
233
+ <key>SKAdNetworkIdentifier</key>
234
+ <string>mlmmfzh3r3.skadnetwork</string>
235
+ </dict>
236
+ <dict>
237
+ <key>SKAdNetworkIdentifier</key>
238
+ <string>578prtvx9j.skadnetwork</string>
239
+ </dict>
240
+ <dict>
241
+ <key>SKAdNetworkIdentifier</key>
242
+ <string>4dzt52r2t5.skadnetwork</string>
243
+ </dict>
244
+ <dict>
245
+ <key>SKAdNetworkIdentifier</key>
246
+ <string>gta9lk7p23.skadnetwork</string>
247
+ </dict>
248
+ <dict>
249
+ <key>SKAdNetworkIdentifier</key>
250
+ <string>e5fvkxwrpn.skadnetwork</string>
251
+ </dict>
252
+ <dict>
253
+ <key>SKAdNetworkIdentifier</key>
254
+ <string>8c4e2ghe7u.skadnetwork</string>
255
+ </dict>
256
+ <dict>
257
+ <key>SKAdNetworkIdentifier</key>
258
+ <string>zq492l623r.skadnetwork</string>
259
+ </dict>
260
+ <dict>
261
+ <key>SKAdNetworkIdentifier</key>
262
+ <string>3rd42ekr43.skadnetwork</string>
263
+ </dict>
264
+ <dict>
265
+ <key>SKAdNetworkIdentifier</key>
266
+ <string>3qcr597p9d.skadnetwork</string>
267
+ </dict>
268
+ </array>
269
+ </config-file>
270
+
271
+ <podspec>
272
+ <config>
273
+ <source url="https://cdn.cocoapods.org/" />
274
+ </config>
275
+ <pods use-frameworks="true">
276
+ <pod name="Google-Mobile-Ads-SDK" spec="~> 10.3.0" />
277
+ </pods>
278
+ </podspec>
279
+
280
+ </platform>
46
281
  </plugin>
@@ -1 +1 @@
1
- package emi.indo.cordova.plugin.admob;import org.apache.cordova.CordovaPlugin;import org.apache.cordova.CallbackContext;import org.json.JSONArray;import org.json.JSONException;import android.util.Log;import org.apache.cordova.CordovaInterface;import org.apache.cordova.CordovaWebView;import android.view.ViewGroup;import android.widget.RelativeLayout;import androidx.annotation.NonNull;import com.google.android.gms.ads.AdListener;import com.google.android.gms.ads.MobileAds;import com.google.android.gms.ads.AdError;import com.google.android.gms.ads.AdRequest;import com.google.android.gms.ads.AdSize;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.ResponseInfo;import com.google.android.gms.ads.VersionInfo;import com.google.android.gms.ads.interstitial.InterstitialAd;import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;import com.google.android.gms.ads.initialization.AdapterStatus;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.FormError;import com.google.android.ump.UserMessagingPlatform;import java.util.Map;import java.util.Objects;public class emiAdmobPlugin extends CordovaPlugin{private static final String TAG="emiAdmobPlugin";private InterstitialAd mInterstitialAd;private RewardedAd rewardedAd;private RewardedInterstitialAd rewardedInterstitialAd;private CordovaWebView cWebView;private RelativeLayout bannerViewLayout;private CallbackContext rewardedCallbacks;private AdView bannerView;static boolean isbannerDestroy=false;static boolean isbannerShow=true;static boolean isinterstitialload=false;static boolean isrewardedInterstitialload=false;static boolean isrewardedload=false;private ConsentInformation consentInformation;private ConsentForm consentForm;public void initialize(CordovaInterface cordova,CordovaWebView webView){super.initialize(cordova,webView);cWebView=webView;}public boolean execute(String action,JSONArray args,final CallbackContext callbackContext)throws JSONException{switch(action){case "initialize":VersionInfo mobileAds=MobileAds.getVersion();MobileAds.initialize(cordova.getActivity(),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()));}}callbackContext.success(mobileAds.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.SdkInitializationComplete');");});return true;case "loadInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String interstitialAdAdUnitId=args.optString(0);final boolean responseInfo=args.optBoolean(1);AdRequest adRequest=new AdRequest.Builder().build();InterstitialAd.load(cordova.getActivity(),interstitialAdAdUnitId,adRequest,new InterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd){isinterstitialload=true;mInterstitialAd=interstitialAd;Log.i(TAG,"onAdLoaded");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdLoaded');");if(responseInfo){ResponseInfo responseInfo=interstitialAd.getResponseInfo();callbackContext.success(responseInfo.toString());}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdFailedToLoad');");callbackContext.error(loadAdError.toString());}});});return true;case "showInterstitialAd":if(isinterstitialload){cordova.getActivity().runOnUiThread(()->{mInterstitialAd.show(cordova.getActivity());});}else{callbackContext.error("The Interstitial ad wasn't ready yet");}return true;case "loadRewardedAd":cordova.getActivity().runOnUiThread(()->{final String rewardedAdAdUnitId=args.optString(0);final boolean responseInfo=args.optBoolean(1);AdRequest adRequest=new AdRequest.Builder().build();RewardedAd.load(cordova.getActivity(),rewardedAdAdUnitId,adRequest,new RewardedAdLoadCallback(){@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());rewardedAd=null;isrewardedload=false;Log.d(TAG,"The rewarded ad wasn't ready yet.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedAdFailedToLoad');");callbackContext.error(loadAdError.toString());}@Override public void onAdLoaded(@NonNull RewardedAd ad){rewardedAd=ad;isrewardedload=true;Log.d(TAG,"Ad was loaded.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedAdLoaded');");if(responseInfo){ResponseInfo responseInfo=ad.getResponseInfo();callbackContext.success(responseInfo.toString());}}});});return true;case "showRewardedAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedload){rewardedAd.show(cordova.getActivity(),rewardItem ->{Log.d(TAG,"The user earned the reward.");int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "loadRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String rewardedInterstitialAdUnitId=args.optString(0);final boolean responseInfo=args.optBoolean(1);RewardedInterstitialAd.load(cordova.getActivity(),rewardedInterstitialAdUnitId,new AdRequest.Builder().build(),new RewardedInterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull RewardedInterstitialAd ad){Log.d(TAG,"Ad was loaded.");rewardedInterstitialAd=ad;isrewardedInterstitialload=true;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedInterstitialAdLoaded');");if(responseInfo){ResponseInfo responseInfo=ad.getResponseInfo();callbackContext.success(responseInfo.toString());}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedInterstitialAdFailedToLoad');");callbackContext.error(loadAdError.toString());}});});return true;case "showRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedInterstitialload){rewardedInterstitialAd.show(cordova.getActivity(),rewardItem ->{Log.d(TAG,"The user earned the reward.");int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{Log.d(TAG,"The rewarded ad wasn't ready yet.");callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "showBannerAd":cordova.getActivity().runOnUiThread(()->{final String bannerAdUnitId=args.optString(0);final String position=args.optString(1);final String size=args.optString(2);final int adaptiveWidth=args.optInt(3);if(isbannerShow){if(bannerViewLayout==null){bannerViewLayout=new RelativeLayout(cordova.getActivity());RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);bannerViewLayout.setLayoutParams(params);((ViewGroup)Objects.requireNonNull(cWebView.getView())).addView(bannerViewLayout);}bannerView=new AdView(cordova.getActivity());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,"Anchored_adaptive")){bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cordova.getActivity(),adaptiveWidth));}else if(Objects.equals(size,"Inline_adaptive")){bannerView.setAdSize(AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(cordova.getActivity(),adaptiveWidth));}else{bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cordova.getActivity(),320));}bannerView.setAdUnitId(bannerAdUnitId);AdRequest adRequest=new AdRequest.Builder().build();bannerView.loadAd(adRequest);isbannerShow=false;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;}isbannerDestroy=true;bannerView.setLayoutParams(bannerParams);bannerViewLayout.addView(bannerView);bannerView.setAdListener(new AdListener(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdClicked');");}@Override public void onAdClosed(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdClosed');");}@Override public void onAdFailedToLoad(@NonNull LoadAdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdFailedToLoad');");callbackContext.error(adError.toString());}@Override public void onAdImpression(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdImpression');");}@Override public void onAdLoaded(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdLoaded');");}@Override public void onAdOpened(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdOpened');");}});}});return true;case "removeBannerAd":cordova.getActivity().runOnUiThread(()->{if(isbannerDestroy){if(bannerView==null)return;RelativeLayout bannerViewLayout=(RelativeLayout)bannerView.getParent();if(bannerViewLayout!=null){bannerViewLayout.removeView(bannerView);bannerView.destroy();bannerView=null;isbannerDestroy=false;isbannerShow=true;}}});return true;case "getConsentRequest":final boolean setTagForUnderAgeOfConsent=args.optBoolean(0);cordova.getActivity().runOnUiThread(()->{ConsentRequestParameters params=new ConsentRequestParameters .Builder().setTagForUnderAgeOfConsent(setTagForUnderAgeOfConsent).build();consentInformation=UserMessagingPlatform.getConsentInformation(cordova.getActivity());consentInformation.requestConsentInfoUpdate(cordova.getActivity(),params,()->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onConsentInfoUpdateSuccess');");if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.NOT_REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.NOT_REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.NOT_REQUIRED');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.OBTAINED){callbackContext.success(ConsentInformation.ConsentStatus.OBTAINED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.OBTAINED');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.REQUIRED');");if(consentInformation.isConsentFormAvailable()){UserMessagingPlatform.loadConsentForm(cordova.getContext(),consentForm ->{consentForm.show(cordova.getActivity(),formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ShowError');");callbackContext.error(String.valueOf(formError));});},formError -> callbackContext.error(formError.getMessage()));cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.loadConsentFormError');");}else{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentFormNotAvailable');");}}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.UNKNOWN){callbackContext.success(ConsentInformation.ConsentStatus.UNKNOWN);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.UNKNOWN');");}},formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onConsentInfoUpdateFailure');");callbackContext.error(formError.getMessage());});});return true;case "consentReset":cordova.getActivity().runOnUiThread(()->{consentInformation.reset();});return true;}mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");mInterstitialAd=null;isinterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdShowedFullScreenContent');");}});rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");rewardedAd=null;isrewardedload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdShowedFullScreenContent');");}});rewardedInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");rewardedInterstitialAd=null;isrewardedInterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdShowedFullScreenContent');");}});return false;}public void onDestroy(){if(bannerView!=null){bannerView.destroy();isbannerDestroy=false;isbannerShow=true;}}}
1
+ package emi.indo.cordova.plugin.admob;import org.apache.cordova.CordovaPlugin;import org.apache.cordova.CallbackContext;import org.json.JSONArray;import org.json.JSONException;import android.annotation.SuppressLint;import android.os.Bundle;import android.util.Log;import org.apache.cordova.CordovaInterface;import org.apache.cordova.CordovaWebView;import org.json.JSONObject;import android.view.ViewGroup;import android.widget.RelativeLayout;import androidx.annotation.NonNull;import com.google.ads.mediation.admob.AdMobAdapter;import com.google.android.gms.ads.AdListener;import com.google.android.gms.ads.AdValue;import com.google.android.gms.ads.MobileAds;import com.google.android.gms.ads.AdError;import com.google.android.gms.ads.AdRequest;import com.google.android.gms.ads.AdSize;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.OnPaidEventListener;import com.google.android.gms.ads.OnUserEarnedRewardListener;import com.google.android.gms.ads.RequestConfiguration;import com.google.android.gms.ads.ResponseInfo;import com.google.android.gms.ads.VersionInfo;import com.google.android.gms.ads.admanager.AdManagerAdRequest;import com.google.android.gms.ads.interstitial.InterstitialAd;import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;import com.google.android.gms.ads.initialization.AdapterStatus;import com.google.android.gms.ads.rewarded.RewardItem;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.FormError;import com.google.android.ump.UserMessagingPlatform;import java.util.Map;import java.util.Objects;public class emiAdmobPlugin extends CordovaPlugin{private static final String TAG="emiAdmobPlugin";private InterstitialAd mInterstitialAd;private RewardedAd rewardedAd;private RewardedInterstitialAd rewardedInterstitialAd;private CordovaWebView cWebView;private RelativeLayout bannerViewLayout;private CallbackContext rewardedCallbacks;private AdView bannerView;static boolean isbannerDestroy=false;static boolean isbannerShow=true;static boolean isinterstitialload=false;static boolean isrewardedInterstitialload=false;static boolean isrewardedload=false;private ConsentInformation consentInformation;private ConsentForm consentForm;public void initialize(CordovaInterface cordova,CordovaWebView webView){super.initialize(cordova,webView);cWebView=webView;}public boolean execute(String action,JSONArray args,final CallbackContext callbackContext)throws JSONException{switch(action){case "initialize":VersionInfo mobileAds=MobileAds.getVersion();MobileAds.initialize(cordova.getActivity(),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()));}}callbackContext.success(mobileAds.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.SdkInitializationComplete');");});return true;case "targeting":cordova.getActivity().runOnUiThread(()->{final boolean TagForChildDirectedTreatment=args.optBoolean(0);final boolean TagForUnderAgeOfConsent=args.optBoolean(1);final String MaxAdContentRating=args.optString(2);if(TagForChildDirectedTreatment){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE).build();MobileAds.setRequestConfiguration(requestConfiguration);}else{RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE).build();MobileAds.setRequestConfiguration(requestConfiguration);}if(TagForUnderAgeOfConsent){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE).build();MobileAds.setRequestConfiguration(requestConfiguration);}else{RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE).build();MobileAds.setRequestConfiguration(requestConfiguration);callbackContext.success(requestConfiguration.toString());}if(Objects.equals(MaxAdContentRating,"G")){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G).build();MobileAds.setRequestConfiguration(requestConfiguration);callbackContext.success(requestConfiguration.toString());}else if(Objects.equals(MaxAdContentRating,"MA")){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_MA).build();MobileAds.setRequestConfiguration(requestConfiguration);callbackContext.success(requestConfiguration.toString());}else if(Objects.equals(MaxAdContentRating,"PG")){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_PG).build();MobileAds.setRequestConfiguration(requestConfiguration);callbackContext.success(requestConfiguration.toString());}else if(Objects.equals(MaxAdContentRating,"T")){RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_T).build();MobileAds.setRequestConfiguration(requestConfiguration);callbackContext.success(requestConfiguration.toString());}else{RequestConfiguration requestConfiguration=MobileAds.getRequestConfiguration().toBuilder().setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED).build();MobileAds.setRequestConfiguration(requestConfiguration);callbackContext.success(requestConfiguration.toString());}});return true;case "loadInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String interstitialAdAdUnitId=args.optString(0);final boolean responseInfo=args.optBoolean(1);final String npa=args.optString(2);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();InterstitialAd.load(cordova.getActivity(),interstitialAdAdUnitId,adRequest,new InterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd){isinterstitialload=true;mInterstitialAd=interstitialAd;Log.i(TAG,"onAdLoaded");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdLoaded');");if(responseInfo){ResponseInfo responseInfo=interstitialAd.getResponseInfo();callbackContext.success(responseInfo.toString());}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdFailedToLoad');");callbackContext.error(loadAdError.toString());}});});return true;case "showInterstitialAd":if(isinterstitialload){cordova.getActivity().runOnUiThread(()->{mInterstitialAd.show(cordova.getActivity());});}else{callbackContext.error("The Interstitial ad wasn't ready yet");}return true;case "loadRewardedAd":cordova.getActivity().runOnUiThread(()->{final String rewardedAdAdUnitId=args.optString(0);final boolean responseInfo=args.optBoolean(1);final String npa=args.optString(2);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedAd.load(cordova.getActivity(),rewardedAdAdUnitId,adRequest,new RewardedAdLoadCallback(){public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());rewardedAd=null;isrewardedload=false;Log.d(TAG,"The rewarded ad wasn't ready yet.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedAdFailedToLoad');");callbackContext.error(loadAdError.toString());}@Override public void onAdLoaded(@NonNull RewardedAd ad){rewardedAd=ad;isrewardedload=true;Log.d(TAG,"Ad was loaded.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedAdLoaded');");if(responseInfo){ResponseInfo responseInfo=ad.getResponseInfo();callbackContext.success(responseInfo.toString());}}});});return true;case "showRewardedAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedload){rewardedAd.show(cordova.getActivity(),rewardItem ->{Log.d(TAG,"The user earned the reward.");int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewarded.rewarded');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "loadRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String rewardedInterstitialAdUnitId=args.optString(0);final boolean responseInfo=args.optBoolean(1);final String npa=args.optString(2);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();RewardedInterstitialAd.load(cordova.getActivity(),rewardedInterstitialAdUnitId,adRequest,new RewardedInterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull RewardedInterstitialAd ad){Log.d(TAG,"Ad was loaded.");rewardedInterstitialAd=ad;isrewardedInterstitialload=true;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedInterstitialAdLoaded');");if(responseInfo){ResponseInfo responseInfo=ad.getResponseInfo();callbackContext.success(responseInfo.toString());}}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.RewardedInterstitialAdFailedToLoad');");callbackContext.error(loadAdError.toString());}});});return true;case "showRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{if(isrewardedInterstitialload){rewardedInterstitialAd.show(cordova.getActivity(),rewardItem ->{Log.d(TAG,"The user earned the reward.");int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitial.rewarded');");callbackContext.success("rewardAmount:"+rewardAmount+"rewardType:"+rewardType);});}else{Log.d(TAG,"The rewarded ad wasn't ready yet.");callbackContext.error("The rewarded ad wasn't ready yet");}});return true;case "showBannerAd":cordova.getActivity().runOnUiThread(()->{final String bannerAdUnitId=args.optString(0);final String position=args.optString(1);final String size=args.optString(2);final int adaptiveWidth=args.optInt(3);final String npa=args.optString(4);if(isbannerShow){if(bannerViewLayout==null){bannerViewLayout=new RelativeLayout(cordova.getActivity());RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,RelativeLayout.LayoutParams.MATCH_PARENT);bannerViewLayout.setLayoutParams(params);((ViewGroup)Objects.requireNonNull(cWebView.getView())).addView(bannerViewLayout);}bannerView=new AdView(cordova.getActivity());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,"Anchored_adaptive")){bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cordova.getActivity(),adaptiveWidth));}else if(Objects.equals(size,"Inline_adaptive")){bannerView.setAdSize(AdSize.getCurrentOrientationInlineAdaptiveBannerAdSize(cordova.getActivity(),adaptiveWidth));}else{bannerView.setAdSize(AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cordova.getActivity(),320));}bannerView.setAdUnitId(bannerAdUnitId);Bundle bundleExtra=new Bundle();bundleExtra.putString("npa",npa);AdRequest adRequest=new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class,bundleExtra).build();bannerView.loadAd(adRequest);isbannerShow=false;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;}isbannerDestroy=true;bannerView.setLayoutParams(bannerParams);bannerViewLayout.addView(bannerView);bannerView.setAdListener(new AdListener(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdClicked');");}@Override public void onAdClosed(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdClosed');");}@Override public void onAdFailedToLoad(@NonNull LoadAdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdFailedToLoad');");callbackContext.error(adError.toString());}@Override public void onAdImpression(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdImpression');");}@Override public void onAdLoaded(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdLoaded');");}@Override public void onAdOpened(){isbannerShow=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.bannerAdOpened');");}});}});return true;case "removeBannerAd":cordova.getActivity().runOnUiThread(()->{if(isbannerDestroy){if(bannerView==null)return;RelativeLayout bannerViewLayout=(RelativeLayout)bannerView.getParent();if(bannerViewLayout!=null){bannerViewLayout.removeView(bannerView);bannerView.destroy();bannerView=null;isbannerDestroy=false;isbannerShow=true;}}});return true;case "getConsentRequest":final boolean setTagForUnderAgeOfConsent=args.optBoolean(0);cordova.getActivity().runOnUiThread(()->{ConsentRequestParameters params=new ConsentRequestParameters .Builder().setTagForUnderAgeOfConsent(setTagForUnderAgeOfConsent).build();consentInformation=UserMessagingPlatform.getConsentInformation(cordova.getActivity());consentInformation.requestConsentInfoUpdate(cordova.getActivity(),params,()->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onConsentInfoUpdateSuccess');");if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.NOT_REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.NOT_REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.NOT_REQUIRED');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.OBTAINED){callbackContext.success(ConsentInformation.ConsentStatus.OBTAINED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.OBTAINED');");}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.REQUIRED){callbackContext.success(ConsentInformation.ConsentStatus.REQUIRED);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.REQUIRED');");if(consentInformation.isConsentFormAvailable()){UserMessagingPlatform.loadConsentForm(cordova.getContext(),consentForm ->{consentForm.show(cordova.getActivity(),formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ShowError');");callbackContext.error(String.valueOf(formError));});},formError -> callbackContext.error(formError.getMessage()));cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.loadConsentFormError');");}else{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentFormNotAvailable');");}}else if(consentInformation.getConsentStatus()==ConsentInformation.ConsentStatus.UNKNOWN){callbackContext.success(ConsentInformation.ConsentStatus.UNKNOWN);cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.ConsentStatus.UNKNOWN');");}},formError ->{cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onConsentInfoUpdateFailure');");callbackContext.error(formError.getMessage());});});return true;case "consentReset":cordova.getActivity().runOnUiThread(()->{consentInformation.reset();});return true;}mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");mInterstitialAd=null;isinterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");mInterstitialAd=null;isinterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.InterstitialAdShowedFullScreenContent');");}});rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");rewardedAd=null;isrewardedload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");rewardedAd=null;isrewardedload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedAdShowedFullScreenContent');");}});rewardedInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdClicked');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");rewardedInterstitialAd=null;isrewardedInterstitialload=false;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdDismissedFullScreenContent');");}@Override public void onAdFailedToShowFullScreenContent(@NonNull AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");rewardedInterstitialAd=null;isrewardedInterstitialload=false;callbackContext.error(adError.toString());cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdFailedToShowFullScreenContent');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdImpression');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('on.rewardedInterstitialAdShowedFullScreenContent');");}});return false;}public void onDestroy(){if(bannerView!=null){bannerView.destroy();isbannerDestroy=false;isbannerShow=true;}super.onDestroy();}}
@@ -0,0 +1,286 @@
1
+ import Foundation
2
+ import GoogleMobileAds
3
+ import UIKit
4
+
5
+ @objc(emiAdmobPlugin)
6
+ public class emiAdmobPlugin : CDVPlugin, GADFullScreenContentDelegate, GADBannerViewDelegate {
7
+
8
+ private var bannerView: GADBannerView!
9
+ private var interstitial: GADInterstitialAd?
10
+ private var rewardedAd: GADRewardedAd?
11
+ private var rewardedInterstitialAd: GADRewardedInterstitialAd?
12
+
13
+ var isBannerShowing = false
14
+
15
+
16
+ @objc
17
+ func initialize(_ command: CDVInvokedUrlCommand) {
18
+
19
+ let ads = GADMobileAds.sharedInstance()
20
+ ads.start { status in
21
+ // Optional: Log each adapter's initialization latency.
22
+ let adapterStatuses = status.adapterStatusesByClassName
23
+ for adapter in adapterStatuses {
24
+ let adapterStatus = adapter.value
25
+ NSLog("Adapter Name: %@, Description: %@, Latency: %f", adapter.key,
26
+ adapterStatus.description, adapterStatus.latency)
27
+ }
28
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.SdkInitializationComplete")
29
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
30
+ }
31
+ }
32
+
33
+
34
+ @objc
35
+ func showBannerAd(_ command: CDVInvokedUrlCommand) {
36
+ let bannerAdUnitId = command.arguments[0] as? String ?? ""
37
+ let position = command.arguments[1] as? String ?? ""
38
+ bannerView = GADBannerView(adSize: GADAdSizeBanner)
39
+ bannerView.adUnitID = bannerAdUnitId
40
+ bannerView.rootViewController = self.viewController
41
+ bannerView.load(GADRequest())
42
+ addBannerViewToView(bannerView, position, view: webView)
43
+ bannerView.delegate = self
44
+ }
45
+
46
+
47
+ func addBannerViewToView(_ bannerView: GADBannerView, _ position: String, view: UIView?) {
48
+
49
+ bannerView.translatesAutoresizingMaskIntoConstraints = false
50
+ view?.addSubview(bannerView)
51
+ if position == "top" {
52
+
53
+ view?.addConstraints(
54
+ [NSLayoutConstraint(item: bannerView,
55
+ attribute: .top,
56
+ relatedBy: .equal,
57
+ toItem: view?.safeAreaLayoutGuide,
58
+ attribute: .top,
59
+ multiplier: 1,
60
+ constant: 0),
61
+ NSLayoutConstraint(item: bannerView,
62
+ attribute: .centerX,
63
+ relatedBy: .equal,
64
+ toItem: view,
65
+ attribute: .centerX,
66
+ multiplier: 1,
67
+ constant: 0)
68
+ ])
69
+
70
+ } else if position == "top-Margin" {
71
+
72
+ view?.addConstraints(
73
+
74
+ [NSLayoutConstraint(item: bannerView,
75
+ attribute: .topMargin,
76
+ relatedBy: .equal,
77
+ toItem: view?.safeAreaLayoutGuide,
78
+ attribute: .topMargin,
79
+ multiplier: 1,
80
+ constant: 0),
81
+ NSLayoutConstraint(item: bannerView,
82
+ attribute: .centerX,
83
+ relatedBy: .equal,
84
+ toItem: view,
85
+ attribute: .centerX,
86
+ multiplier: 1,
87
+ constant: 0)
88
+ ])
89
+
90
+ } else if position == "bottom" {
91
+
92
+ view?.addConstraints(
93
+
94
+ [NSLayoutConstraint(item: bannerView,
95
+ attribute: .bottom,
96
+ relatedBy: .equal,
97
+ toItem: view?.safeAreaLayoutGuide,
98
+ attribute: .bottom,
99
+ multiplier: 1,
100
+ constant: 0),
101
+ NSLayoutConstraint(item: bannerView,
102
+ attribute: .centerX,
103
+ relatedBy: .equal,
104
+ toItem: view,
105
+ attribute: .centerX,
106
+ multiplier: 1,
107
+ constant: 0)
108
+ ])
109
+
110
+
111
+ } else if position == "bottom-Margin" {
112
+
113
+ view?.addConstraints(
114
+
115
+ [NSLayoutConstraint(item: bannerView,
116
+ attribute: .bottomMargin,
117
+ relatedBy: .equal,
118
+ toItem: view?.safeAreaLayoutGuide,
119
+ attribute: .bottomMargin,
120
+ multiplier: 1,
121
+ constant: 0),
122
+ NSLayoutConstraint(item: bannerView,
123
+ attribute: .centerX,
124
+ relatedBy: .equal,
125
+ toItem: view,
126
+ attribute: .centerX,
127
+ multiplier: 1,
128
+ constant: 0)
129
+ ])
130
+
131
+
132
+
133
+ } else {
134
+
135
+
136
+ view?.addConstraints(
137
+
138
+ [NSLayoutConstraint(item: bannerView,
139
+ attribute: .bottomMargin,
140
+ relatedBy: .equal,
141
+ toItem: view?.safeAreaLayoutGuide,
142
+ attribute: .bottomMargin,
143
+ multiplier: 1,
144
+ constant: 0),
145
+ NSLayoutConstraint(item: bannerView,
146
+ attribute: .centerX,
147
+ relatedBy: .equal,
148
+ toItem: view,
149
+ attribute: .centerX,
150
+ multiplier: 1,
151
+ constant: 0)
152
+ ])
153
+ }
154
+ }
155
+
156
+
157
+ @objc
158
+ func removeBannerAd(_ command: CDVInvokedUrlCommand) {
159
+
160
+ if(bannerView != nil){
161
+ self.isBannerShowing = true;
162
+ }
163
+
164
+ if(self.isBannerShowing){
165
+
166
+ self.isBannerShowing = self.unLoadBanner(self.bannerView)
167
+ }
168
+ }
169
+
170
+ func unLoadBanner(_ bannerView: UIView?) -> Bool{
171
+ bannerView?.removeFromSuperview()
172
+ return false
173
+ }
174
+
175
+
176
+ @objc
177
+ func loadInterstitialAd(_ command: CDVInvokedUrlCommand) {
178
+
179
+ let interstitialAdAdUnitId = command.arguments[0] as? String ?? ""
180
+
181
+ let request = GADRequest()
182
+ GADInterstitialAd.load(withAdUnitID: interstitialAdAdUnitId,
183
+ request: request,
184
+ completionHandler: { [self] ad, error in
185
+ if let error = error {
186
+ print("Failed to load interstitial ad with error: \(error.localizedDescription)")
187
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.InterstitialAdFailedToLoad")
188
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
189
+ return
190
+ }
191
+
192
+ self.interstitial = ad
193
+ self.interstitial?.fullScreenContentDelegate = self
194
+
195
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.InterstitialAdLoaded")
196
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
197
+
198
+ } )
199
+
200
+ }
201
+
202
+ @objc
203
+ func showInterstitialAd(_ command: CDVInvokedUrlCommand) {
204
+ if interstitial != nil {
205
+ interstitial?.present(fromRootViewController: self.viewController)
206
+ } else {
207
+ print("Ad wasn't ready")
208
+ }
209
+ }
210
+
211
+ @objc
212
+ func loadRewardedAd(_ command: CDVInvokedUrlCommand) {
213
+ let rewardedAdAdUnitId = command.arguments[0] as? String ?? ""
214
+ let request = GADRequest()
215
+ GADRewardedAd.load(
216
+ withAdUnitID:rewardedAdAdUnitId,
217
+ request: request,
218
+ completionHandler: {
219
+ [self] ad, error in
220
+ if let error = error {
221
+ print("Failed to load rewarded ad with error: \(error.localizedDescription)")
222
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.RewardedAdFailedToLoad")
223
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
224
+ return
225
+ }
226
+ rewardedAd = ad
227
+ print("Rewarded ad loaded.")
228
+
229
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.RewardedAdLoaded")
230
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
231
+ }
232
+ )
233
+ }
234
+
235
+ @objc
236
+ func showRewardedAd(_ command: CDVInvokedUrlCommand) {
237
+
238
+ if let ad = rewardedAd {
239
+ ad.present(fromRootViewController: self.viewController) {
240
+ let reward = ad.adReward
241
+ print("Reward received with currency \(reward.amount), amount \(reward.amount.doubleValue)")
242
+ // TODO: Reward the user.
243
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.rewarded.rewarded")
244
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
245
+ }
246
+ } else {
247
+ print("Ad wasn't ready")
248
+ }
249
+ }
250
+
251
+
252
+ @objc
253
+ func loadRewardedInterstitialAd(_ command: CDVInvokedUrlCommand) {
254
+ let interstitialAdAdUnitId = command.arguments[0] as? String ?? ""
255
+ GADRewardedInterstitialAd.load(
256
+ withAdUnitID:interstitialAdAdUnitId,
257
+ request: GADRequest()) { ad, error in
258
+ if let error = error {
259
+ return print("Failed to load rewarded interstitial ad with error: \(error.localizedDescription)")
260
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.RewardedInterstitialAdFailedToLoad")
261
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
262
+ }
263
+ self.rewardedInterstitialAd = ad
264
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.RewardedInterstitialAdLoaded")
265
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
266
+ }
267
+ }
268
+
269
+ @objc
270
+ func showRewardedInterstitialAd(_ command: CDVInvokedUrlCommand) {
271
+
272
+ if rewardedInterstitialAd != nil {
273
+ rewardedInterstitialAd?.present(fromRootViewController: self.viewController) {
274
+ // let reward = rewardedInterstitialAd?.adReward
275
+ // TODO: Reward the user!
276
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.rewardedInterstitial.rewarded")
277
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
278
+ }
279
+ } else {
280
+ print("Ad wasn't ready")
281
+ }
282
+ }
283
+
284
+
285
+
286
+ }
@@ -4,32 +4,32 @@ exports.initialize = function (arg0, success, error) {
4
4
  exec(success, error, 'emiAdmobPlugin', 'initialize', [arg0]);
5
5
  };
6
6
 
7
- exports.showBannerAd = function (arg0, arg1, arg2, arg3, success, error) {
8
- exec(success, error, 'emiAdmobPlugin', 'showBannerAd', [arg0, arg1, arg2, arg3]);
7
+ exports.showBannerAd = function (arg0, arg1, arg2, arg3, arg4, success, error) {
8
+ exec(success, error, 'emiAdmobPlugin', 'showBannerAd', [arg0, arg1, arg2, arg3, arg4]);
9
9
  };
10
10
 
11
11
  exports.removeBannerAd = function (arg0, success, error) {
12
12
  exec(success, error, 'emiAdmobPlugin', 'removeBannerAd', [arg0]);
13
13
  };
14
14
 
15
- exports.loadInterstitialAd = function (arg0, arg1, success, error) {
16
- exec(success, error, 'emiAdmobPlugin', 'loadInterstitialAd', [arg0, arg1]);
15
+ exports.loadInterstitialAd = function (arg0, arg1, arg2, success, error) {
16
+ exec(success, error, 'emiAdmobPlugin', 'loadInterstitialAd', [arg0, arg1, arg2]);
17
17
  };
18
18
 
19
19
  exports.showInterstitialAd = function (arg0, success, error) {
20
20
  exec(success, error, 'emiAdmobPlugin', 'showInterstitialAd', [arg0]);
21
21
  };
22
22
 
23
- exports.loadRewardedAd = function (arg0, arg1, success, error) {
24
- exec(success, error, 'emiAdmobPlugin', 'loadRewardedAd', [arg0, arg1]);
23
+ exports.loadRewardedAd = function (arg0, arg1, arg2, success, error) {
24
+ exec(success, error, 'emiAdmobPlugin', 'loadRewardedAd', [arg0, arg1, arg2]);
25
25
  };
26
26
 
27
27
  exports.showRewardedAd = function (arg0, success, error) {
28
28
  exec(success, error, 'emiAdmobPlugin', 'showRewardedAd', [arg0]);
29
29
  };
30
30
 
31
- exports.loadRewardedInterstitialAd = function (arg0, arg1, success, error) {
32
- exec(success, error, 'emiAdmobPlugin', 'loadRewardedInterstitialAd', [arg0, arg1]);
31
+ exports.loadRewardedInterstitialAd = function (arg0, arg1, arg2, success, error) {
32
+ exec(success, error, 'emiAdmobPlugin', 'loadRewardedInterstitialAd', [arg0, arg1, arg2]);
33
33
  };
34
34
 
35
35
  exports.showRewardedInterstitialAd = function (arg0, success, error) {
@@ -42,4 +42,8 @@ exports.getConsentRequest = function (arg0, success, error) {
42
42
 
43
43
  exports.consentReset = function (arg0, success, error) {
44
44
  exec(success, error, 'emiAdmobPlugin', 'consentReset', [arg0]);
45
+ };
46
+
47
+ exports.targeting = function (arg0, arg1, arg2, success, error) {
48
+ exec(success, error, 'emiAdmobPlugin', 'targeting', [arg0, arg1, arg2]);
45
49
  };