cordova-admob-tomitank 1.3.5 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-admob-tomitank",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "Trustable Google AdMob Cordova Plugin",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-admob-tomitank" version="1.3.5"
2
+ <plugin id="cordova-admob-tomitank" version="1.3.6"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
  <name>cordova-admob-tomitank</name>
@@ -31,7 +31,6 @@ import admob.plus.core.Ad;
31
31
 
32
32
  import static admob.plus.core.Helper.ads;
33
33
 
34
-
35
34
  public class AdMob extends CordovaPlugin implements Helper.Adapter {
36
35
  public static final String NATIVE_VIEW_DEFAULT = Native.VIEW_DEFAULT_KEY;
37
36
  private static final String TAG = "AdMobPlus";
@@ -74,29 +73,34 @@ public class AdMob extends CordovaPlugin implements Helper.Adapter {
74
73
  break;
75
74
  case Actions.AD_CREATE:
76
75
  String adClass = ctx.optString("cls");
77
- if (adClass == null) {
76
+ if (adClass == null) { // class missing..
78
77
  ctx.reject("ad cls is missing");
79
78
  } else {
80
79
  GenericAd ad = null;
81
- switch (adClass) {
82
- case "AppOpenAd":
83
- ad = new AppOpen(ctx);
84
- break;
85
- case "BannerAd":
86
- ad = new Banner(ctx);
87
- break;
88
- case "InterstitialAd":
89
- ad = new Interstitial(ctx);
90
- break;
91
- case "NativeAd":
92
- ad = new Native(ctx);
93
- break;
94
- case "RewardedAd":
95
- ad = new Rewarded(ctx);
96
- break;
97
- case "RewardedInterstitialAd":
98
- ad = new RewardedInterstitial(ctx);
99
- break;
80
+ String id = ctx.optId();
81
+ if (id != null && helper.ads.containsKey(id)) {
82
+ ad = (GenericAd) helper.getAd(id); // already exists..
83
+ } else {
84
+ switch (adClass) {
85
+ case "AppOpenAd":
86
+ ad = new AppOpen(ctx);
87
+ break;
88
+ case "BannerAd":
89
+ ad = new Banner(ctx);
90
+ break;
91
+ case "InterstitialAd":
92
+ ad = new Interstitial(ctx);
93
+ break;
94
+ case "NativeAd":
95
+ ad = new Native(ctx);
96
+ break;
97
+ case "RewardedAd":
98
+ ad = new Rewarded(ctx);
99
+ break;
100
+ case "RewardedInterstitialAd":
101
+ ad = new RewardedInterstitial(ctx);
102
+ break;
103
+ }
100
104
  }
101
105
  if (ad != null) {
102
106
  ctx.resolve();
@@ -91,31 +91,36 @@ class AMBPlugin: CDVPlugin {
91
91
  let ctx = AMBContext(command)
92
92
 
93
93
  DispatchQueue.main.async {
94
- if let adClass = ctx.optString("cls") {
94
+ let adClass = ctx.optString("cls")
95
+ if adClass == nil { // class missing..
96
+ ctx.reject("ad cls is missing")
97
+ } else {
95
98
  var ad: AMBCoreAd?
96
- switch adClass {
97
- case "AppOpenAd":
98
- ad = AMBAppOpenAd(ctx)
99
- case "BannerAd":
100
- ad = AMBBanner(ctx)
101
- case "InterstitialAd":
102
- ad = AMBInterstitial(ctx)
103
- case "NativeAd":
104
- ad = AMBNativeAd(ctx)
105
- case "RewardedAd":
106
- ad = AMBRewarded(ctx)
107
- case "RewardedInterstitialAd":
108
- ad = AMBRewardedInterstitial(ctx)
109
- default:
110
- break
99
+ if let id = ctx.optId(), let existing = AMBCoreAd.ads[id] {
100
+ ad = existing // already exists..
101
+ } else {
102
+ switch adClass {
103
+ case "AppOpenAd":
104
+ ad = AMBAppOpenAd(ctx)
105
+ case "BannerAd":
106
+ ad = AMBBanner(ctx)
107
+ case "InterstitialAd":
108
+ ad = AMBInterstitial(ctx)
109
+ case "NativeAd":
110
+ ad = AMBNativeAd(ctx)
111
+ case "RewardedAd":
112
+ ad = AMBRewarded(ctx)
113
+ case "RewardedInterstitialAd":
114
+ ad = AMBRewardedInterstitial(ctx)
115
+ default:
116
+ break
117
+ }
111
118
  }
112
119
  if ad != nil {
113
120
  ctx.resolve()
114
121
  } else {
115
122
  ctx.reject("fail to create ad: \(ctx.optId() ?? "-")")
116
123
  }
117
- } else {
118
- ctx.reject()
119
124
  }
120
125
  }
121
126
  }