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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,11 +36,16 @@ https://user-images.githubusercontent.com/78555833/228323239-e9e18e74-b814-4ca8-
36
36
  - Interstitial Ads
37
37
  - Rewarded Ads
38
38
  - Rewarded interstitial Ads
39
+ - [Consent](https://github.com/EMI-INDO/emi-indo-cordova-plugin-consent)
40
+ - Mediation
39
41
 
40
42
  ## Coming soon
41
43
  - App Open Ads
42
- - User Consent
43
- - Mediation ( In the process )
44
+ - User Consent ( Finished ) [emi-indo-cordova-plugin-consent](https://github.com/EMI-INDO/emi-indo-cordova-plugin-consent)
45
+ - Mediation ( Finished )
46
+
47
+
48
+
44
49
 
45
50
 
46
51
  ## Installation
@@ -326,8 +331,7 @@ alert("on.banner Ad Loaded");
326
331
  - right
327
332
  - bottom-center
328
333
  - bottom-right
329
- - adaptiveWidth = number
330
- > default: 320
334
+
331
335
 
332
336
 
333
337
  ### size
@@ -338,10 +342,13 @@ alert("on.banner Ad Loaded");
338
342
  - MEDIUM_RECTANGLE
339
343
  - FULL_BANNER
340
344
  - LEADERBOARD
345
+ - adaptiveWidth = number
341
346
  - Smart Banners = DEPRECATED
342
347
  - default: Anchored_adaptive
343
348
 
344
349
 
350
+
351
+
345
352
  ### Event Load a Show
346
353
 
347
354
  - on.bannerAdClicked
@@ -519,12 +526,17 @@ cordova plugin add emi-indo-cordova-plugin-mediation-meta --variable META_ADAPTE
519
526
  - ================================
520
527
 
521
528
 
522
-
529
+ emi-indo-cordova-plugin-admob@0.0.5
523
530
 
524
531
 
525
532
  > - ## 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)
533
+ - [emi-indo-cordova-plugin-admob@0.0.4](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/%400.0.4)
534
+
535
+ - [emi-indo-cordova-plugin-admob@0.0.5](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/v0.0.5)
536
+
537
+ <img src="https://user-images.githubusercontent.com/78555833/231241800-8834ca2a-fa95-4cc2-91ca-1478c6b3c1ef.jpg" width="250">
527
538
 
539
+ - [emi-indo-cordova-plugin-admob@0.0.6](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/releases/tag/v0.0.6)
528
540
 
529
541
 
530
542
  ### Platform Support
@@ -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>
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.6",
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.6">
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,258 @@
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
+
14
+ @objc
15
+ func initialize(_ command: CDVInvokedUrlCommand) {
16
+
17
+ GADMobileAds.sharedInstance().start(completionHandler: nil)
18
+
19
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.SdkInitializationComplete")
20
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
21
+
22
+ }
23
+
24
+
25
+ @objc
26
+ func showbannerAd(_ command: CDVInvokedUrlCommand) {
27
+ let bannerAdUnitId = command.arguments[0] as? String ?? ""
28
+ let position = command.arguments[1] as? String ?? ""
29
+ bannerView = GADBannerView(adSize: GADAdSizeBanner)
30
+ bannerView.adUnitID = bannerAdUnitId
31
+ bannerView.rootViewController = self.viewController
32
+ bannerView.load(GADRequest())
33
+ addBannerViewToView(bannerView, position, view: webView)
34
+ bannerView.delegate = self
35
+ }
36
+
37
+
38
+ func addBannerViewToView(_ bannerView: GADBannerView, _ position: String, view: UIView?) {
39
+
40
+ bannerView.translatesAutoresizingMaskIntoConstraints = false
41
+ view?.addSubview(bannerView)
42
+ if position == "top" {
43
+
44
+ view?.addConstraints(
45
+ [NSLayoutConstraint(item: bannerView,
46
+ attribute: .top,
47
+ relatedBy: .equal,
48
+ toItem: view?.safeAreaLayoutGuide,
49
+ attribute: .top,
50
+ multiplier: 1,
51
+ constant: 0),
52
+ NSLayoutConstraint(item: bannerView,
53
+ attribute: .centerX,
54
+ relatedBy: .equal,
55
+ toItem: view,
56
+ attribute: .centerX,
57
+ multiplier: 1,
58
+ constant: 0)
59
+ ])
60
+
61
+ } else if position == "top-Margin" {
62
+
63
+ view?.addConstraints(
64
+
65
+ [NSLayoutConstraint(item: bannerView,
66
+ attribute: .topMargin,
67
+ relatedBy: .equal,
68
+ toItem: view?.safeAreaLayoutGuide,
69
+ attribute: .topMargin,
70
+ multiplier: 1,
71
+ constant: 0),
72
+ NSLayoutConstraint(item: bannerView,
73
+ attribute: .centerX,
74
+ relatedBy: .equal,
75
+ toItem: view,
76
+ attribute: .centerX,
77
+ multiplier: 1,
78
+ constant: 0)
79
+ ])
80
+
81
+ } else if position == "bottom" {
82
+
83
+ view?.addConstraints(
84
+
85
+ [NSLayoutConstraint(item: bannerView,
86
+ attribute: .bottom,
87
+ relatedBy: .equal,
88
+ toItem: view?.safeAreaLayoutGuide,
89
+ attribute: .bottom,
90
+ multiplier: 1,
91
+ constant: 0),
92
+ NSLayoutConstraint(item: bannerView,
93
+ attribute: .centerX,
94
+ relatedBy: .equal,
95
+ toItem: view,
96
+ attribute: .centerX,
97
+ multiplier: 1,
98
+ constant: 0)
99
+ ])
100
+
101
+
102
+ } else if position == "bottom-Margin" {
103
+
104
+ view?.addConstraints(
105
+
106
+ [NSLayoutConstraint(item: bannerView,
107
+ attribute: .bottomMargin,
108
+ relatedBy: .equal,
109
+ toItem: view?.safeAreaLayoutGuide,
110
+ attribute: .bottomMargin,
111
+ multiplier: 1,
112
+ constant: 0),
113
+ NSLayoutConstraint(item: bannerView,
114
+ attribute: .centerX,
115
+ relatedBy: .equal,
116
+ toItem: view,
117
+ attribute: .centerX,
118
+ multiplier: 1,
119
+ constant: 0)
120
+ ])
121
+
122
+
123
+
124
+ } else {
125
+
126
+
127
+ view?.addConstraints(
128
+
129
+ [NSLayoutConstraint(item: bannerView,
130
+ attribute: .bottomMargin,
131
+ relatedBy: .equal,
132
+ toItem: view?.safeAreaLayoutGuide,
133
+ attribute: .bottomMargin,
134
+ multiplier: 1,
135
+ constant: 0),
136
+ NSLayoutConstraint(item: bannerView,
137
+ attribute: .centerX,
138
+ relatedBy: .equal,
139
+ toItem: view,
140
+ attribute: .centerX,
141
+ multiplier: 1,
142
+ constant: 0)
143
+ ])
144
+ }
145
+ }
146
+
147
+
148
+ @objc
149
+ func loadInterstitialAd(_ command: CDVInvokedUrlCommand) {
150
+
151
+ let interstitialAdAdUnitId = command.arguments[0] as? String ?? ""
152
+
153
+ let request = GADRequest()
154
+ GADInterstitialAd.load(withAdUnitID: interstitialAdAdUnitId,
155
+ request: request,
156
+ completionHandler: { [self] ad, error in
157
+ if let error = error {
158
+ print("Failed to load interstitial ad with error: \(error.localizedDescription)")
159
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.InterstitialAdFailedToLoad")
160
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
161
+ return
162
+ }
163
+
164
+ self.interstitial = ad
165
+ self.interstitial?.fullScreenContentDelegate = self
166
+
167
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.InterstitialAdLoaded")
168
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
169
+
170
+ } )
171
+
172
+ }
173
+
174
+ @objc
175
+ func showInterstitialAd(_ command: CDVInvokedUrlCommand) {
176
+ if interstitial != nil {
177
+ interstitial?.present(fromRootViewController: self.viewController)
178
+ } else {
179
+ print("Ad wasn't ready")
180
+ }
181
+ }
182
+
183
+ @objc
184
+ func loadRewardedAd(_ command: CDVInvokedUrlCommand) {
185
+ let rewardedAdAdUnitId = command.arguments[0] as? String ?? ""
186
+ let request = GADRequest()
187
+ GADRewardedAd.load(
188
+ withAdUnitID:rewardedAdAdUnitId,
189
+ request: request,
190
+ completionHandler: {
191
+ [self] ad, error in
192
+ if let error = error {
193
+ print("Failed to load rewarded ad with error: \(error.localizedDescription)")
194
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.RewardedAdFailedToLoad")
195
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
196
+ return
197
+ }
198
+ rewardedAd = ad
199
+ print("Rewarded ad loaded.")
200
+
201
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.RewardedAdLoaded")
202
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
203
+ }
204
+ )
205
+ }
206
+
207
+ @objc
208
+ func showRewardedAd(_ command: CDVInvokedUrlCommand) {
209
+
210
+ if let ad = rewardedAd {
211
+ ad.present(fromRootViewController: self.viewController) {
212
+ let reward = ad.adReward
213
+ print("Reward received with currency \(reward.amount), amount \(reward.amount.doubleValue)")
214
+ // TODO: Reward the user.
215
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.rewarded.rewarded")
216
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
217
+ }
218
+ } else {
219
+ print("Ad wasn't ready")
220
+ }
221
+ }
222
+
223
+
224
+ @objc
225
+ func loadRewardedInterstitialAd(_ command: CDVInvokedUrlCommand) {
226
+ let interstitialAdAdUnitId = command.arguments[0] as? String ?? ""
227
+ GADRewardedInterstitialAd.load(
228
+ withAdUnitID:interstitialAdAdUnitId,
229
+ request: GADRequest()) { ad, error in
230
+ if let error = error {
231
+ return print("Failed to load rewarded interstitial ad with error: \(error.localizedDescription)")
232
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.RewardedInterstitialAdFailedToLoad")
233
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
234
+ }
235
+ self.rewardedInterstitialAd = ad
236
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.RewardedInterstitialAdLoaded")
237
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
238
+ }
239
+ }
240
+
241
+ @objc
242
+ func showRewardedInterstitialAd(_ command: CDVInvokedUrlCommand) {
243
+
244
+ if rewardedInterstitialAd != nil {
245
+ rewardedInterstitialAd?.present(fromRootViewController: self.viewController) {
246
+ // let reward = rewardedInterstitialAd?.adReward
247
+ // TODO: Reward the user!
248
+ let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "on.rewardedInterstitial.rewarded")
249
+ self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
250
+ }
251
+ } else {
252
+ print("Ad wasn't ready")
253
+ }
254
+ }
255
+
256
+
257
+
258
+ }
@@ -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
  };