cordova-plugin-admob-nextgen 2.0.2-beta.1 → 2.0.3-beta.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/README.md CHANGED
@@ -115,7 +115,7 @@ This plugin is regularly updated to support the latest standards.
115
115
 
116
116
  | Component | Platform | Version | Release Notes |
117
117
  | :--- | :--- | :--- | :--- |
118
- | **GMA Next-Gen SDK** | Android | **1.3.0** | [View Notes](https://developers.google.com/admob/android/next-gen/rel-notes) |
118
+ | **GMA Next-Gen SDK** | Android | **1.4.0** | [View Notes](https://developers.google.com/admob/android/next-gen/rel-notes) |
119
119
  | **UMP SDK** | Android | **4.0.0** | [View Notes](https://developers.google.com/admob/android/privacy/release-notes) |
120
120
  | **Mobile Ads SDK** | iOS | **13.3.0** | [View Notes](https://developers.google.com/admob/ios/rel-notes) |
121
121
  | **UMP SDK** | iOS | **3.1.0** | [View Notes](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download) |
@@ -158,7 +158,7 @@ function run() {
158
158
  admob = {
159
159
  APP_ID_ANDROID: appIdAndroid ? appIdAndroid[1] : "ca-app-pub-3940256099942544~3347511713",
160
160
  APP_ID_IOS: appIdIos ? appIdIos[1] : "ca-app-pub-3940256099942544~1458002511",
161
- NEXT_GEN_SDK_VERSION: sdk ? sdk[1] : "1.2.1",
161
+ NEXT_GEN_SDK_VERSION: sdk ? sdk[1] : "1.4.0",
162
162
  UMP_VERSION: ump ? ump[1] : "4.0.0"
163
163
  };
164
164
  }
@@ -167,7 +167,7 @@ function run() {
167
167
  injectExclusionRules();
168
168
  if (admob?.NEXT_GEN_SDK_VERSION || admob?.UMP_VERSION) {
169
169
  updateGradleDependencies(
170
- admob.NEXT_GEN_SDK_VERSION || "1.2.1",
170
+ admob.NEXT_GEN_SDK_VERSION || "1.4.0",
171
171
  admob.UMP_VERSION || "4.0.0"
172
172
  );
173
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-admob-nextgen",
3
- "version": "2.0.2-beta.1",
3
+ "version": "2.0.3-beta.1",
4
4
  "description": "Google Mobile Ads Next Gen SDK for Cordova. High performance and modular architecture. ",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-admob-nextgen",
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
2
  <plugin id="cordova-plugin-admob-nextgen"
3
- version="2.0.1"
3
+ version="2.0.3-beta.1"
4
4
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
5
5
  xmlns:android="http://schemas.android.com/apk/res/android">
6
6
 
@@ -26,6 +26,7 @@
26
26
 
27
27
  <config-file parent="/*" target="AndroidManifest.xml">
28
28
  <uses-permission android:name="android.permission.INTERNET" />
29
+ <uses-permission android:name="com.google.android.gms.permission.AD_ID" />
29
30
  </config-file>
30
31
 
31
32
  <!-- hooks: Prevent conflicts with legacy SDKs when using mediation -->
@@ -53,7 +54,7 @@
53
54
 
54
55
  </platform>
55
56
 
56
- <preference name="NEXT_GEN_SDK_VERSION" default="1.3.0" />
57
+ <preference name="NEXT_GEN_SDK_VERSION" default="1.4.0" />
57
58
  <preference name="UMP_VERSION" default="4.0.0" />
58
59
  <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
59
60
  <preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
@@ -52,6 +52,7 @@ public class AdMobNextGen extends CordovaPlugin {
52
52
 
53
53
  private boolean isNativeValidatorDisabled = true;
54
54
  public static boolean isInitialized = false;
55
+ public static boolean isAppInForeground = true;
55
56
 
56
57
  @Override
57
58
  public void pluginInitialize() {
@@ -300,6 +301,7 @@ public class AdMobNextGen extends CordovaPlugin {
300
301
  @Override
301
302
  public void onResume(boolean multitasking) {
302
303
  super.onResume(multitasking);
304
+ isAppInForeground = true;
303
305
  if (appOpenAdExecutor != null && appOpenAdExecutor.shouldAutoShow()) {
304
306
  appOpenAdExecutor.showAdIfAvailable(cordova.getActivity());
305
307
  }
@@ -310,6 +312,12 @@ public class AdMobNextGen extends CordovaPlugin {
310
312
  }
311
313
  }
312
314
 
315
+ @Override
316
+ public void onPause(boolean multitasking) {
317
+ super.onPause(multitasking);
318
+ isAppInForeground = false;
319
+ }
320
+
313
321
  private void initializeSDK(JSONArray args, CallbackContext callbackContext) {
314
322
  String appId = getAppIdFromManifest();
315
323
  if (appId == null) {
@@ -203,10 +203,23 @@ public class AppOpenAdExecutor {
203
203
  }
204
204
  });
205
205
 
206
- isShowingAd = true;
207
206
  cordova.getActivity().runOnUiThread(() -> {
207
+
208
+ if (!AdMobNextGen.isAppInForeground) {
209
+ try {
210
+ JSONObject errData = new JSONObject();
211
+ errData.put("code", "APP_IN_BACKGROUND");
212
+ errData.put("message", "Ad presentation blocked: Application is currently in the background.");
213
+ fireEvent("on.appopen.failed.show", errData);
214
+ } catch (JSONException e) {}
215
+
216
+ return;
217
+ }
218
+
219
+ isShowingAd = true;
208
220
  appOpenAd.show(activity);
209
221
  });
222
+
210
223
  }
211
224
 
212
225
  public boolean shouldAutoShow() {
@@ -84,6 +84,11 @@ public class InterstitialExecutor {
84
84
  requestCallback.success("Ad already loaded and ready");
85
85
  }
86
86
  fireEvent("on.interstitial.loaded", null);
87
+
88
+ if (isAutoShow) {
89
+ showInterstitialAd();
90
+ }
91
+
87
92
  return;
88
93
  }
89
94
 
@@ -115,6 +120,7 @@ public class InterstitialExecutor {
115
120
  if (isAutoShow) {
116
121
  showInterstitialAd();
117
122
  }
123
+
118
124
  }
119
125
 
120
126
  @Override
@@ -152,6 +158,17 @@ public class InterstitialExecutor {
152
158
  Activity activity = cordova.getActivity();
153
159
 
154
160
  activity.runOnUiThread(() -> {
161
+
162
+ if (!AdMobNextGen.isAppInForeground) {
163
+ try {
164
+ JSONObject errData = new JSONObject();
165
+ errData.put("code", "APP_IN_BACKGROUND");
166
+ errData.put("message", "Ad presentation blocked: Application is currently in the background.");
167
+ fireEvent("on.interstitial.failed.show", errData);
168
+ } catch (JSONException e) {}
169
+ return;
170
+ }
171
+
155
172
  interstitialAd.setAdEventCallback(new InterstitialAdEventCallback() {
156
173
 
157
174
  @Override
@@ -84,6 +84,11 @@ public class RewardedExecutor {
84
84
  if (rewardedAd != null) {
85
85
 
86
86
  fireEvent("on.rewarded.loaded", null);
87
+
88
+ if (isAutoShow) {
89
+ showRewardedAd();
90
+ }
91
+
87
92
  return;
88
93
  }
89
94
 
@@ -155,6 +160,16 @@ public class RewardedExecutor {
155
160
 
156
161
  isRewardEarned = false;
157
162
 
163
+ if (!AdMobNextGen.isAppInForeground) {
164
+ try {
165
+ JSONObject errData = new JSONObject();
166
+ errData.put("code", "APP_IN_BACKGROUND");
167
+ errData.put("message", "Ad presentation blocked: Application is currently in the background.");
168
+ fireEvent("on.rewarded.failed.show", errData);
169
+ } catch (JSONException e) {}
170
+ return;
171
+ }
172
+
158
173
  rewardedAd.setAdEventCallback(new RewardedAdEventCallback() {
159
174
 
160
175
  @Override
@@ -73,6 +73,11 @@ public class RewardedInterstitialExecutor {
73
73
  if (callbackContext != null) {
74
74
  callbackContext.success("Ad already loaded");
75
75
  }
76
+
77
+ if (isAutoShow) {
78
+ showRewardedInterstitial(null);
79
+ }
80
+
76
81
  return;
77
82
  }
78
83
 
@@ -138,6 +143,16 @@ public class RewardedInterstitialExecutor {
138
143
 
139
144
  isRewardEarned = false;
140
145
 
146
+ if (!AdMobNextGen.isAppInForeground) {
147
+ try {
148
+ JSONObject errData = new JSONObject();
149
+ errData.put("code", "APP_IN_BACKGROUND");
150
+ errData.put("message", "Ad presentation blocked: Application is currently in the background.");
151
+ fireEvent("on.rewardedInter.failed.show", errData);
152
+ } catch (JSONException e) {}
153
+ return;
154
+ }
155
+
141
156
  mRewardedInterstitialAd.setAdEventCallback(new RewardedInterstitialAdEventCallback() {
142
157
 
143
158
  @Override