emi-indo-cordova-plugin-admob 0.0.1

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/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,13 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # npm/emi-indo-cordova-plugin-admob
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13
+ custom: ['paypal.me/emiindo']
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 EMI-INDO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # emi-indo-cordova-plugin-admob
2
+ Cordova Plugin Admob Android
3
+
4
+ ### Mobile Ads SDK (Android: 21.5.0)
5
+
6
+
7
+ > __Warning__
8
+ > - ## This plugin is still BETA (in progress).
9
+
10
+ > __Note__
11
+ > - ## It's Not a fork, it's purely rewritten, clean of 3rd party code.
12
+
13
+ > __Note__
14
+ > - ### No Ad-Sharing
15
+ > - ### No Remote Control
16
+ > - ### I guarantee 100% revenue for you.
17
+
18
+
19
+ ## Features
20
+
21
+ - Banner ads
22
+ - Interstitial ads
23
+ - Rewarded ads
24
+ - Rewarded interstitial ads
25
+ - App Open Ads (Coming soon)
26
+
27
+
28
+
29
+
30
+ ## Installation
31
+
32
+ ```sh
33
+ emi-indo-cordova-plugin-admob --variable APP_ID_ANDROID=ca-app-pub-3940256099942544~3347511713
34
+ ```
35
+
36
+
37
+ ## deviceready
38
+
39
+ ```sh
40
+ // Before loading ads, have your app initialize the Google Mobile Ads SDK by calling
41
+ // This needs to be done only once, ideally at app launch.
42
+
43
+ cordova.plugins.emiAdmobPlugin.initialize();
44
+
45
+ document.addEventListener('onInitializationComplete', () => {
46
+
47
+ alert("on Initialization Complete");
48
+
49
+ });
50
+
51
+
52
+ ```
53
+ ## Banner ads
54
+
55
+ ```sh
56
+ var AdUnitId = {
57
+
58
+ bannerAdUnitId: "ca-app-pub-3940256099942544/6300978111",
59
+ InterstitialAdAdUnitId: "ca-app-pub-3940256099942544/1033173712",
60
+ RewardedInterstitialAdUnitId: "ca-app-pub-3940256099942544/5354046379",
61
+ RewardedAdAdUnitId: "ca-app-pub-3940256099942544/5224354917"
62
+
63
+
64
+ }
65
+
66
+ /// setting banner size: BANNER | LARGE_BANNER | MEDIUM_RECTANGLE | FULL_BANNER | LEADERBOARD | default: "" = BANNER
67
+ var size = "LARGE_BANNER"
68
+ /// setting banner position: top-right | top-center | left | center | right | bottom-center | bottom-right | default: "" = bottom-left
69
+ var position = "bottom-center"
70
+
71
+
72
+ // Load a Show cordova.plugins.emiAdmobPlugin.showBannerAd(AdUnitId.bannerAdUnitId, size, position);
73
+ // remove cordova.plugins.emiAdmobPlugin.removeBannerAd();
74
+
75
+ ```
76
+
77
+ [Banner ads event](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob#-banner-ads-) - callback:
78
+
79
+
80
+ ## Interstitial ads
81
+
82
+ ```sh
83
+
84
+ // Load cordova.plugins.emiAdmobPlugin.loadInterstitialAd(AdUnitId.InterstitialAdAdUnitId);
85
+
86
+ // Show cordova.plugins.emiAdmobPlugin.showInterstitialAd();
87
+
88
+ ```
89
+ [Interstitial ads event](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob#-interstitial-ads-) - callback:
90
+
91
+
92
+
93
+ ## Rewarded ads
94
+
95
+ ```sh
96
+
97
+ // Load cordova.plugins.emiAdmobPlugin.loadRewardedAd(AdUnitId.RewardedAdAdUnitId);
98
+
99
+ // Show cordova.plugins.emiAdmobPlugin.showRewardedAd();
100
+
101
+ ```
102
+
103
+ [Rewarded ads event](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob#-rewarded-ads-) - callback:
104
+
105
+
106
+ ## Rewarded interstitial ads
107
+
108
+ ```sh
109
+
110
+ // Load cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd(AdUnitId.RewardedInterstitialAdUnitId);
111
+
112
+ // Show cordova.plugins.emiAdmobPlugin.showRewardedInterstitialAd();
113
+
114
+ ```
115
+
116
+ [Rewarded interstitial ads event](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob#-rewarded-ads-) - callback:
117
+
118
+
119
+
120
+
121
+
122
+
123
+ # Event | callback:
124
+ ### event code
125
+
126
+ ```sh
127
+ document.addEventListener('onAdLoaded.bannerAd', () => {
128
+
129
+ alert("on Ad Loaded banner");
130
+
131
+ });
132
+
133
+ ```
134
+
135
+ ## ( Banner ads )
136
+
137
+ ### Event Show a load
138
+
139
+ - onAdClicked.bannerAd
140
+ - onAdClosed.bannerAd
141
+ - onAdFailedToLoad.bannerAd
142
+ - onAdImpression.bannerAd
143
+ - onAdLoaded.bannerAd
144
+ - onAdOpened.bannerAd
145
+
146
+
147
+
148
+
149
+ ## ( Interstitial ads )
150
+
151
+ ### Event Load
152
+
153
+ - onAdLoaded.InterstitialAd
154
+ - onAdFailedToLoad.InterstitialAd
155
+
156
+ ### Event Show
157
+
158
+ - onAdClicked.InterstitialAd
159
+ - onAdDismissedFullScreenContent.InterstitialAd
160
+ - onAdFailedToShowFullScreenContent.InterstitialAd
161
+ - onAdImpression.InterstitialAd
162
+ - onAdShowedFullScreenContent.InterstitialAd
163
+
164
+
165
+
166
+
167
+ ## ( Rewarded ads )
168
+
169
+ ### Event Load
170
+
171
+ - onAdFailedToLoad.RewardedAd
172
+ - onAdLoaded.RewardedAd
173
+
174
+
175
+ ### Event Show
176
+
177
+ - onAdClicked.rewardedAd
178
+ - onAdDismissedFullScreenContent.rewardedAd
179
+ - onAdFailedToShowFullScreenContent.rewardedAd
180
+ - onAdImpression.rewardedAd
181
+ - onAdShowedFullScreenContent.rewardedAd
182
+
183
+
184
+
185
+ ## ( Rewarded interstitial ads )
186
+
187
+ ### Event Load
188
+
189
+ - onAdLoaded.RewardedInterstitial
190
+ - onAdFailedToLoad.RewardedInterstitial
191
+
192
+
193
+ ### Event Show
194
+
195
+ - onAdClicked.rewardedInterstitialAd
196
+ - onAdDismissedFullScreenContent.rewardedInterstitialAd
197
+ - onAdFailedToShowFullScreenContent.rewardedInterstitialAd
198
+ - onAdImpression.rewardedInterstitialAd
199
+ - onAdShowedFullScreenContent.rewardedInterstitialAd
200
+
201
+
202
+ ## 💰Sponsor this project
203
+ [![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://paypal.me/emiindo)
204
+
@@ -0,0 +1,59 @@
1
+ <html>
2
+ <head>
3
+ <script type="text/javascript" src="cordova.js"></script>
4
+ </head>
5
+ <body>
6
+
7
+ <script>
8
+
9
+
10
+
11
+ /// setting banner size: BANNER | LARGE_BANNER | MEDIUM_RECTANGLE | FULL_BANNER | LEADERBOARD | default: "" = BANNER
12
+ var size = "LARGE_BANNER"
13
+ /// setting banner position: top-right | top-center | left | center | right | bottom-center | bottom-right | default: "" = bottom-left
14
+ var position = "bottom-center"
15
+
16
+
17
+ var AdUnitId = {
18
+
19
+ bannerAdUnitId: "ca-app-pub-3940256099942544/6300978111",
20
+ InterstitialAdAdUnitId: "ca-app-pub-3940256099942544/1033173712",
21
+ RewardedInterstitialAdUnitId: "ca-app-pub-3940256099942544/5354046379",
22
+ RewardedAdAdUnitId: "ca-app-pub-3940256099942544/5224354917"
23
+
24
+ }
25
+
26
+
27
+
28
+
29
+
30
+
31
+ document.addEventListener("deviceready", function(){
32
+
33
+ cordova.plugins.emiAdmobPlugin.initialize();
34
+
35
+
36
+
37
+ // event
38
+
39
+ document.addEventListener('onInitializationComplete', () => {
40
+
41
+ alert("on Initialization Complete");
42
+
43
+ });
44
+
45
+
46
+
47
+ }, false);
48
+ </script>
49
+
50
+ <p> <button onclick="cordova.plugins.emiAdmobPlugin.showBannerAd(AdUnitId.bannerAdUnitId, size, position);">Show Banner Ad</button></p>
51
+ <p> <button onclick="cordova.plugins.emiAdmobPlugin.removeBannerAd();">remove Banner Ad</button></p>
52
+ <p> <button onclick="cordova.plugins.emiAdmobPlugin.loadInterstitialAd(AdUnitId.InterstitialAdAdUnitId);">Load Interstitial Ad</button></p>
53
+ <p> <button onclick="cordova.plugins.emiAdmobPlugin.showInterstitialAd();">Show Interstitial Ad</button></p>
54
+ <p> <button onclick="cordova.plugins.emiAdmobPlugin.loadRewardedInterstitialAd(AdUnitId.RewardedInterstitialAdUnitId);">Load Rewarded Interstitial</button></p>
55
+ <p> <button onclick="cordova.plugins.emiAdmobPlugin.showRewardedInterstitialAd();">Show Rewarded Interstitial</button></p>
56
+
57
+
58
+ </body>
59
+ </html>
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "emi-indo-cordova-plugin-admob",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "cordova": {
6
+ "id": "emi-indo-cordova-plugin-admob",
7
+ "platforms": [
8
+ "android"
9
+ ]
10
+ },
11
+ "keywords": [
12
+ "ecosystem:cordova",
13
+ "cordova-android",
14
+ "javascript",
15
+ "admob",
16
+ "cordova-plugin-admob",
17
+ "admob-free",
18
+ "admob-plus",
19
+ "admob-pro",
20
+ "construct 3"
21
+
22
+ ],
23
+ "author": "EMI INDO",
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/issues"
31
+ },
32
+ "homepage": "https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob#readme"
33
+ }
package/plugin.xml ADDED
@@ -0,0 +1,42 @@
1
+ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="emi-indo-cordova-plugin-admob" version="0.0.1">
2
+ <name>emiAdmobPlugin</name>
3
+
4
+ <js-module src="www/emiAdmobPlugin.js" name="emiAdmobPlugin">
5
+ <clobbers target="cordova.plugins.emiAdmobPlugin"/>
6
+ </js-module>
7
+
8
+ <engines>
9
+
10
+ <engine name="cordova" version=">=7.0.0" />
11
+ <engine name="cordova-android" version=">=6.0.0" />
12
+
13
+ </engines>
14
+
15
+
16
+ <platform name="android">
17
+ <config-file parent="/*" target="res/xml/config.xml">
18
+ <feature name="emiAdmobPlugin">
19
+ <param name="android-package" value="emi.indo.cordova.plugin.admob.emiAdmobPlugin"/>
20
+ </feature>
21
+ </config-file>
22
+
23
+
24
+ <config-file target="AndroidManifest.xml" parent="/manifest/application">
25
+ <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:excludeFromRecents="true" android:name="com.google.android.gms.ads.AdActivity" android:noHistory="true" />
26
+ <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="$APP_ID_ANDROID" />
27
+ <meta-data android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT" android:value="true"/>
28
+ </config-file>
29
+
30
+ <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
31
+
32
+ <preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
33
+ <preference name="PLAY_SERVICES_VERSION" default="21.5.0" />
34
+
35
+ <framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />
36
+
37
+
38
+ <config-file parent="/*" target="AndroidManifest.xml"/>
39
+ <source-file src="src/android/emiAdmobPlugin.java" target-dir="src/emi/indo/cordova/plugin/admob/emiAdmobPlugin"/>
40
+
41
+ </platform>
42
+ </plugin>
@@ -0,0 +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 org.json.JSONObject;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.OnUserEarnedRewardListener;import com.google.android.gms.ads.initialization.InitializationStatus;import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;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.interstitial.InterstitialAd;import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback;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 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 AdView bannerView;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":cordova.getActivity().runOnUiThread(()-> MobileAds.initialize(cordova.getActivity(),initializationStatus -> cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onInitializationComplete');")));return true;case "loadInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String InterstitialAdAdUnitId=args.optString(0);AdRequest adRequest=new AdRequest.Builder().build();InterstitialAd.load(cordova.getActivity(),InterstitialAdAdUnitId,adRequest,new InterstitialAdLoadCallback(){@Override public void onAdLoaded(@NonNull InterstitialAd interstitialAd){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdLoaded.InterstitialAd');");mInterstitialAd=interstitialAd;Log.i(TAG,"onAdLoaded");}@Override public void onAdFailedToLoad(@NonNull LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());mInterstitialAd=null;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdFailedToLoad.InterstitialAd');");}});});return true;case "showInterstitialAd":cordova.getActivity().runOnUiThread(()->{mInterstitialAd.show(cordova.getActivity());});return true;case "loadRewardedAd":cordova.getActivity().runOnUiThread(()->{final String RewardedAdAdUnitId=args.optString(0);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;Log.d(TAG,"The rewarded ad wasn't ready yet.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdFailedToLoad.RewardedAd');");}@Override public void onAdLoaded(@NonNull RewardedAd ad){rewardedAd=ad;Log.d(TAG,"Ad was loaded.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdLoaded.RewardedAd');");}});});return true;case "showRewardedAd":cordova.getActivity().runOnUiThread(()->{if(rewardedAd!=null){rewardedAd.show(cordova.getActivity(),rewardItem ->{Log.d(TAG,"The user earned the reward.");int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();});}else{Log.d(TAG,"The rewarded ad wasn't ready yet.");}});return true;case "loadRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{final String RewardedInterstitialAdUnitId=args.optString(0);RewardedInterstitialAd.load(cordova.getActivity(),RewardedInterstitialAdUnitId,new AdRequest.Builder().build(),new RewardedInterstitialAdLoadCallback(){@Override public void onAdLoaded(RewardedInterstitialAd ad){Log.d(TAG,"Ad was loaded.");rewardedInterstitialAd=ad;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdLoaded.RewardedInterstitial');");}@Override public void onAdFailedToLoad(LoadAdError loadAdError){Log.d(TAG,loadAdError.toString());rewardedInterstitialAd=null;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdFailedToLoad.RewardedInterstitial');");}});});return true;case "showRewardedInterstitialAd":cordova.getActivity().runOnUiThread(()->{if(rewardedInterstitialAd!=null){rewardedInterstitialAd.show(cordova.getActivity(),rewardItem ->{Log.d(TAG,"The user earned the reward.");int rewardAmount=rewardItem.getAmount();String rewardType=rewardItem.getType();});}else{Log.d(TAG,"The rewarded ad wasn't ready yet.");}});return true;case "showBannerAd":cordova.getActivity().runOnUiThread(()->{final String bannerAdUnitId=args.optString(0);final String size=args.optString(1);final String position=args.optString(2);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{bannerView.setAdSize(AdSize.BANNER);}bannerView.setAdUnitId(bannerAdUnitId);AdRequest adRequest=new AdRequest.Builder().build();bannerView.loadAd(adRequest);RelativeLayout.LayoutParams bannerParams=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);switch(position){case "top-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;case "top-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "left":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "center":bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);bannerParams.addRule(RelativeLayout.CENTER_VERTICAL);break;case "bottom-center":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);break;case "bottom-right":bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);break;default:bannerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);bannerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);break;}bannerView.setLayoutParams(bannerParams);bannerViewLayout.addView(bannerView);});return true;case "removeBannerAd":cordova.getActivity().runOnUiThread(()->{if(bannerView==null)return;ViewGroup parentView=(ViewGroup)bannerView.getParent();if(parentView!=null){parentView.removeView(bannerView);bannerView.destroy();bannerView=null;}});return true;}bannerView.setAdListener(new AdListener(){@Override public void onAdClicked(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdClicked.bannerAd');");}@Override public void onAdClosed(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdClosed.bannerAd');");}@Override public void onAdFailedToLoad(LoadAdError adError){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdFailedToLoad.bannerAd');");}@Override public void onAdImpression(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdImpression.bannerAd');");}@Override public void onAdLoaded(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdLoaded.bannerAd');");}@Override public void onAdOpened(){cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdOpened.bannerAd');");}});mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdClicked.InterstitialAd');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");mInterstitialAd=null;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdDismissedFullScreenContent.InterstitialAd');");}@Override public void onAdFailedToShowFullScreenContent(AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");mInterstitialAd=null;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdFailedToShowFullScreenContent.InterstitialAd');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdImpression.InterstitialAd');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdShowedFullScreenContent.InterstitialAd');");}});rewardedAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdClicked.rewardedAd');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");rewardedAd=null;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdDismissedFullScreenContent.rewardedAd');");}@Override public void onAdFailedToShowFullScreenContent(AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");rewardedAd=null;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdFailedToShowFullScreenContent.rewardedAd');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdImpression.rewardedAd');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdShowedFullScreenContent.rewardedAd');");}});rewardedInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback(){@Override public void onAdClicked(){Log.d(TAG,"Ad was clicked.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdClicked.rewardedInterstitialAd');");}@Override public void onAdDismissedFullScreenContent(){Log.d(TAG,"Ad dismissed fullscreen content.");rewardedInterstitialAd=null;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdDismissedFullScreenContent.rewardedInterstitialAd');");}@Override public void onAdFailedToShowFullScreenContent(AdError adError){Log.e(TAG,"Ad failed to show fullscreen content.");rewardedInterstitialAd=null;cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdFailedToShowFullScreenContent.rewardedInterstitialAd');");}@Override public void onAdImpression(){Log.d(TAG,"Ad recorded an impression.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdImpression.rewardedInterstitialAd');");}@Override public void onAdShowedFullScreenContent(){Log.d(TAG,"Ad showed fullscreen content.");cWebView.loadUrl("javascript:cordova.fireDocumentEvent('onAdShowedFullScreenContent.rewardedInterstitialAd');");}});return false;}}
@@ -0,0 +1,38 @@
1
+ var exec = require('cordova/exec');
2
+
3
+
4
+ exports.initialize = function (arg0, success, error) {
5
+ exec(success, error, 'emiAdmobPlugin', 'initialize', [arg0]);
6
+ };
7
+
8
+ exports.showBannerAd = function (bannerAdUnitId, size, position, success, error) {
9
+ exec(success, error, 'emiAdmobPlugin', 'showBannerAd', [bannerAdUnitId, size, position]);
10
+ };
11
+
12
+ exports.removeBannerAd = function (arg0, success, error) {
13
+ exec(success, error, 'emiAdmobPlugin', 'removeBannerAd', [arg0]);
14
+ };
15
+
16
+ exports.loadInterstitialAd = function (arg0, success, error) {
17
+ exec(success, error, 'emiAdmobPlugin', 'loadInterstitialAd', [arg0]);
18
+ };
19
+
20
+ exports.showInterstitialAd = function (arg0, success, error) {
21
+ exec(success, error, 'emiAdmobPlugin', 'showInterstitialAd', [arg0]);
22
+ };
23
+
24
+ exports.loadRewardedAd = function (arg0, success, error) {
25
+ exec(success, error, 'emiAdmobPlugin', 'loadRewardedAd', [arg0]);
26
+ };
27
+
28
+ exports.showRewardedAd = function (arg0, success, error) {
29
+ exec(success, error, 'emiAdmobPlugin', 'showRewardedAd', [arg0]);
30
+ };
31
+
32
+ exports.loadRewardedInterstitialAd = function (arg0, success, error) {
33
+ exec(success, error, 'emiAdmobPlugin', 'loadRewardedInterstitialAd', [arg0]);
34
+ };
35
+
36
+ exports.showRewardedInterstitialAd = function (arg0, success, error) {
37
+ exec(success, error, 'emiAdmobPlugin', 'showRewardedInterstitialAd', [arg0]);
38
+ };