cordova-plugin-admob-nextgen 1.6.9 → 1.8.9

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
@@ -17,6 +17,8 @@ It moves away from legacy implementations to modern `SurfaceControl`, optimized
17
17
 
18
18
  > **Maintained by the original creator of [EMI-INDO/emi-indo-cordova-plugin-admob](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob).** This is not just an update; it is a brand new engine designed for 2026 and beyond.
19
19
 
20
+ ---
21
+ > (NEW) ⚡️ Next-Gen special capacitor: [capacitor-admob-nextgen](https://github.com/swaplab-engine/capacitor-admob-nextgen)
20
22
  ---
21
23
 
22
24
  ## 🚀 Why Next-Gen?
@@ -113,7 +115,7 @@ This plugin is regularly updated to support the latest standards.
113
115
 
114
116
  | Component | Platform | Version | Release Notes |
115
117
  | :--- | :--- | :--- | :--- |
116
- | **GMA Next-Gen SDK** | Android | **1.1.1** | [View Notes](https://developers.google.com/admob/android/next-gen/rel-notes) |
118
+ | **GMA Next-Gen SDK** | Android | **1.2.0** | [View Notes](https://developers.google.com/admob/android/next-gen/rel-notes) |
117
119
  | **UMP SDK** | Android | **4.0.0** | [View Notes](https://developers.google.com/admob/android/privacy/release-notes) |
118
120
  | **Mobile Ads SDK** | iOS | **13.3.0** | [View Notes](https://developers.google.com/admob/ios/rel-notes) |
119
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.1.1",
161
+ NEXT_GEN_SDK_VERSION: sdk ? sdk[1] : "1.2.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.1.1",
170
+ admob.NEXT_GEN_SDK_VERSION || "1.2.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": "1.6.9",
3
+ "version": "1.8.9",
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="1.6.9"
3
+ version="1.8.9"
4
4
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
5
5
  xmlns:android="http://schemas.android.com/apk/res/android">
6
6
 
@@ -53,7 +53,7 @@
53
53
 
54
54
  </platform>
55
55
 
56
- <preference name="NEXT_GEN_SDK_VERSION" default="1.1.1" />
56
+ <preference name="NEXT_GEN_SDK_VERSION" default="1.2.0" />
57
57
  <preference name="UMP_VERSION" default="4.0.0" />
58
58
  <!-- Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713 -->
59
59
  <preference name="APP_ID_ANDROID" default="ca-app-pub-3940256099942544~3347511713" />
@@ -80,6 +80,9 @@ public class InterstitialExecutor {
80
80
 
81
81
  if (interstitialAd != null) {
82
82
 
83
+ if (requestCallback != null) {
84
+ requestCallback.success("Ad already loaded and ready");
85
+ }
83
86
  fireEvent("on.interstitial.loaded", null);
84
87
  return;
85
88
  }
@@ -117,7 +120,6 @@ public class InterstitialExecutor {
117
120
  @Override
118
121
  public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
119
122
  isLoading = false;
120
- interstitialAd = null;
121
123
 
122
124
  try {
123
125
  JSONObject errData = new JSONObject();
@@ -67,6 +67,15 @@ public class RewardedInterstitialExecutor {
67
67
  return;
68
68
  }
69
69
 
70
+ if (mRewardedInterstitialAd != null) {
71
+
72
+ fireEvent("on.rewardedInter.loaded", null);
73
+ if (callbackContext != null) {
74
+ callbackContext.success("Ad already loaded");
75
+ }
76
+ return;
77
+ }
78
+
70
79
  if ((currentTime - lastLoadTime) < minLoadInterval) {
71
80
 
72
81
  if (callbackContext != null) callbackContext.error("Request too fast. Please wait " + minLoadInterval + " ms to prevent invalid traffic.");
@@ -110,8 +119,6 @@ public class RewardedInterstitialExecutor {
110
119
  public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
111
120
  isLoading = false;
112
121
 
113
- mRewardedInterstitialAd = null;
114
-
115
122
  try {
116
123
  JSONObject err = new JSONObject();
117
124
  err.put("code", loadAdError.getCode());
@@ -156,12 +163,13 @@ public class RewardedInterstitialExecutor {
156
163
  @Override
157
164
  public void onAdDismissedFullScreenContent() {
158
165
 
166
+ mRewardedInterstitialAd = null;
167
+
159
168
  if (!isRewardEarned) {
160
169
  fireEvent("on.rewardedInter.canceled", null);
161
170
  }
162
171
 
163
172
  fireEvent("on.rewardedInter.dismissed", null);
164
- mRewardedInterstitialAd = null;
165
173
  }
166
174
 
167
175
  @Override
@@ -8,10 +8,11 @@
8
8
  #import "RewardedInterstitialExecutor.h"
9
9
 
10
10
  @interface AdMobNextGen()
11
+ @property (nonatomic, assign) BOOL isInitialized;
11
12
  @property (nonatomic, strong) ConsentExecutor *consentExecutor;
12
13
  @property (nonatomic, strong) GlobalSettingsExecutor *globalSettingsExecutor;
13
14
  @property (nonatomic, strong) BannerExecutor *bannerExecutor;
14
- @property (nonatomic, strong) InterstitialExecutor *interstitialExecutor;
15
+ @property (nonatomic, strong) InterstitialExecutor *interstitialExecutor;
15
16
  @property (nonatomic, strong) RewardedExecutor *rewardedExecutor;
16
17
  @property (nonatomic, strong) RewardedInterstitialExecutor *rewardedInterstitialExecutor;
17
18
  @end
@@ -23,15 +24,50 @@
23
24
  self.consentExecutor = [[ConsentExecutor alloc] initWithPlugin:self];
24
25
  self.globalSettingsExecutor = [[GlobalSettingsExecutor alloc] initWithPlugin:self];
25
26
  self.bannerExecutor = [[BannerExecutor alloc] initWithPlugin:self];
26
- self.interstitialExecutor = [[InterstitialExecutor alloc] initWithPlugin:self];
27
+ self.interstitialExecutor = [[InterstitialExecutor alloc] initWithPlugin:self];
27
28
  self.rewardedExecutor = [[RewardedExecutor alloc] initWithPlugin:self];
28
29
  [[AppOpenAdExecutor sharedInstance] initializeWithPlugin:self];
29
30
  self.rewardedInterstitialExecutor = [[RewardedInterstitialExecutor alloc] initWithPlugin:self];
30
31
  }
31
32
 
32
33
  - (void)initialize:(CDVInvokedUrlCommand*)command {
34
+ NSDictionary *options = nil;
35
+ if (command.arguments.count > 0 && [command.arguments objectAtIndex:0] != [NSNull null]) {
36
+ options = [command.arguments objectAtIndex:0];
37
+ }
38
+
39
+ if (options != nil && [options isKindOfClass:[NSDictionary class]]) {
40
+ GADRequestConfiguration *requestConfig = GADMobileAds.sharedInstance.requestConfiguration;
41
+
42
+ if (options[@"maxAdContentRating"]) {
43
+ NSString *rating = options[@"maxAdContentRating"];
44
+ if ([rating isEqualToString:@"G"]) {
45
+ requestConfig.maxAdContentRating = GADMaxAdContentRatingGeneral;
46
+ } else if ([rating isEqualToString:@"PG"]) {
47
+ requestConfig.maxAdContentRating = GADMaxAdContentRatingParentalGuidance;
48
+ } else if ([rating isEqualToString:@"T"]) {
49
+ requestConfig.maxAdContentRating = GADMaxAdContentRatingTeen;
50
+ } else if ([rating isEqualToString:@"MA"]) {
51
+ requestConfig.maxAdContentRating = GADMaxAdContentRatingMatureAudience;
52
+ } else {
53
+ requestConfig.maxAdContentRating = @"";
54
+ }
55
+ }
56
+
57
+ if (options[@"tagForChildDirectedTreatment"]) {
58
+ BOOL isChildDirected = [options[@"tagForChildDirectedTreatment"] boolValue];
59
+ requestConfig.tagForChildDirectedTreatment = @(isChildDirected);
60
+ }
61
+
62
+ if (options[@"tagForUnderAgeOfConsent"]) {
63
+ BOOL isUnderAge = [options[@"tagForUnderAgeOfConsent"] boolValue];
64
+ requestConfig.tagForUnderAgeOfConsent = @(isUnderAge);
65
+ }
66
+ }
67
+
33
68
  [self.commandDelegate runInBackground:^{
34
69
  [[GADMobileAds sharedInstance] startWithCompletionHandler:^(GADInitializationStatus * _Nonnull status) {
70
+ self.isInitialized = YES;
35
71
  CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Initialization complete."];
36
72
  [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
37
73
  }];
@@ -85,6 +121,11 @@
85
121
  #pragma mark - Banner Routing
86
122
 
87
123
  - (void)createBanner:(CDVInvokedUrlCommand*)command {
124
+ if (!self.isInitialized) {
125
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"SDK not initialized. Call initialize() first."];
126
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
127
+ return;
128
+ }
88
129
  NSDictionary *options = [command.arguments objectAtIndex:0];
89
130
  if (options != nil && [options isKindOfClass:[NSDictionary class]]) {
90
131
  [self.bannerExecutor createBanner:options command:command];
@@ -109,6 +150,11 @@
109
150
  #pragma mark - Interstitial Routing
110
151
 
111
152
  - (void)createInterstitial:(CDVInvokedUrlCommand*)command {
153
+ if (!self.isInitialized) {
154
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"SDK not initialized. Call initialize() first."];
155
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
156
+ return;
157
+ }
112
158
  NSDictionary *options = [command.arguments objectAtIndex:0];
113
159
  if (options != nil && [options isKindOfClass:[NSDictionary class]]) {
114
160
  [self.interstitialExecutor createInterstitial:options command:command];
@@ -123,6 +169,11 @@
123
169
  }
124
170
 
125
171
  - (void)createRewarded:(CDVInvokedUrlCommand*)command {
172
+ if (!self.isInitialized) {
173
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"SDK not initialized. Call initialize() first."];
174
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
175
+ return;
176
+ }
126
177
  NSDictionary *options = [command.arguments objectAtIndex:0];
127
178
  if (options != nil) {
128
179
  [self.rewardedExecutor createRewarded:options command:command];
@@ -134,6 +185,11 @@
134
185
  }
135
186
 
136
187
  - (void)loadAppOpenAd:(CDVInvokedUrlCommand*)command {
188
+ if (!self.isInitialized) {
189
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"SDK not initialized. Call initialize() first."];
190
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
191
+ return;
192
+ }
137
193
  NSDictionary *options = [command.arguments objectAtIndex:0];
138
194
  if (options != nil) {
139
195
  [[AppOpenAdExecutor sharedInstance] loadAppOpenAd:options command:command];
@@ -145,6 +201,11 @@
145
201
  }
146
202
 
147
203
  - (void)createRewardedInterstitial:(CDVInvokedUrlCommand*)command {
204
+ if (!self.isInitialized) {
205
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"SDK not initialized. Call initialize() first."];
206
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
207
+ return;
208
+ }
148
209
  NSDictionary *options = [command.arguments objectAtIndex:0];
149
210
  if (options != nil) {
150
211
  [self.rewardedInterstitialExecutor createRewardedInterstitial:options command:command];
@@ -84,6 +84,11 @@
84
84
  }
85
85
 
86
86
  if ((currentTime - self.lastLoadTime) < self.minLoadInterval) {
87
+
88
+ NSString *errorMsg = [NSString stringWithFormat:@"Request too fast. Please wait %.0fms to prevent invalid traffic.", (self.minLoadInterval * 1000.0)];
89
+
90
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMsg];
91
+ [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
87
92
  return;
88
93
  }
89
94
 
@@ -1,27 +1,28 @@
1
1
  #import "BannerExecutor.h"
2
2
  #import "AdMobNextGen.h"
3
3
 
4
- @interface BannerExecutor()
4
+ @interface BannerExecutor ()
5
5
 
6
- @property (nonatomic, weak) AdMobNextGen *plugin;
7
- @property (nonatomic, strong) GADBannerView *bannerView;
6
+ @property(nonatomic, weak) AdMobNextGen *plugin;
7
+ @property(nonatomic, strong) GADBannerView *bannerView;
8
+ @property(nonatomic, strong) GADBannerView *pendingBannerView;
8
9
 
9
- @property (nonatomic, strong) NSString *lastAdUnitId;
10
- @property (nonatomic, strong) NSString *lastSizeStr;
11
- @property (nonatomic, strong) NSString *currentPosition;
12
- @property (nonatomic, strong) NSString *lastPosition;
13
- @property (nonatomic, assign) GADAdSize lastAdSize;
10
+ @property(nonatomic, strong) NSString *lastAdUnitId;
11
+ @property(nonatomic, strong) NSString *lastSizeStr;
12
+ @property(nonatomic, strong) NSString *currentPosition;
13
+ @property(nonatomic, strong) NSString *lastPosition;
14
+ @property(nonatomic, assign) GADAdSize lastAdSize;
14
15
 
15
- @property (nonatomic, assign) BOOL isBannerVisible;
16
- @property (nonatomic, assign) BOOL isLoading;
17
- @property (nonatomic, assign) BOOL isOverlapping;
18
- @property (nonatomic, assign) BOOL isAutoShow;
19
- @property (nonatomic, assign) BOOL isCollapsible;
16
+ @property(nonatomic, assign) BOOL isBannerVisible;
17
+ @property(nonatomic, assign) BOOL isLoading;
18
+ @property(nonatomic, assign) BOOL isOverlapping;
19
+ @property(nonatomic, assign) BOOL isAutoShow;
20
+ @property(nonatomic, assign) BOOL isCollapsible;
20
21
 
21
- @property (nonatomic, assign) CGFloat activeBannerHeight;
22
+ @property(nonatomic, assign) CGFloat activeBannerHeight;
22
23
 
23
- @property (nonatomic, assign) NSTimeInterval lastLoadTime;
24
- @property (nonatomic, assign) NSTimeInterval minLoadInterval;
24
+ @property(nonatomic, assign) NSTimeInterval lastLoadTime;
25
+ @property(nonatomic, assign) NSTimeInterval minLoadInterval;
25
26
 
26
27
  @end
27
28
 
@@ -47,10 +48,11 @@
47
48
  self.lastLoadTime = 0;
48
49
  self.minLoadInterval = 5.0;
49
50
 
50
- [[NSNotificationCenter defaultCenter] addObserver:self
51
- selector:@selector(layoutViews)
52
- name:UIDeviceOrientationDidChangeNotification
53
- object:nil];
51
+ [[NSNotificationCenter defaultCenter]
52
+ addObserver:self
53
+ selector:@selector(layoutViews)
54
+ name:UIDeviceOrientationDidChangeNotification
55
+ object:nil];
54
56
  }
55
57
  return self;
56
58
  }
@@ -59,92 +61,129 @@
59
61
  [[NSNotificationCenter defaultCenter] removeObserver:self];
60
62
  }
61
63
 
62
- #pragma mark - Smart Window Helper (Diadopsi dari EmiBanner)
64
+ #pragma mark - Smart Window Helper
63
65
 
64
66
  - (UIWindow *)getKeyWindow {
65
67
  UIWindow *window = nil;
66
68
  if (@available(iOS 13.0, *)) {
67
- for (UIWindowScene *windowScene in [UIApplication sharedApplication].connectedScenes) {
68
- if (windowScene.activationState == UISceneActivationStateForegroundActive) {
69
+ for (UIWindowScene *windowScene in [UIApplication sharedApplication]
70
+ .connectedScenes) {
71
+ if (windowScene.activationState ==
72
+ UISceneActivationStateForegroundActive) {
69
73
  for (UIWindow *w in windowScene.windows) {
70
- if (w.isKeyWindow) { window = w; break; }
74
+ if (w.isKeyWindow) {
75
+ window = w;
76
+ break;
77
+ }
71
78
  }
72
79
  }
73
- if (window) break;
80
+ if (window)
81
+ break;
74
82
  }
75
83
  }
76
84
  if (!window) {
77
- #pragma clang diagnostic push
78
- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
85
+ #pragma clang diagnostic push
86
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
79
87
  window = [UIApplication sharedApplication].keyWindow;
80
- #pragma clang diagnostic pop
88
+ #pragma clang diagnostic pop
81
89
  }
82
90
  return window;
83
91
  }
84
92
 
85
93
  #pragma mark - Main Methods
86
94
 
87
- - (void)createBanner:(NSDictionary *)options command:(CDVInvokedUrlCommand *)command {
95
+ - (void)createBanner:(NSDictionary *)options
96
+ command:(CDVInvokedUrlCommand *)command {
88
97
  NSString *adUnitId = options[@"adUnitId"];
89
98
  NSString *requestedSize = options[@"size"] ? options[@"size"] : @"ADAPTIVE";
90
- NSString *newPosition = options[@"position"] ? options[@"position"] : self.currentPosition;
91
-
92
- BOOL newIsOverlapping = options[@"isOverlapping"] ? [options[@"isOverlapping"] boolValue] : YES;
93
- BOOL newIsAutoShow = options[@"isAutoShow"] ? [options[@"isAutoShow"] boolValue] : YES;
94
- BOOL newIsCollapsible = options[@"collapsible"] ? [options[@"collapsible"] boolValue] : NO;
95
- NSTimeInterval newMinLoadInterval = options[@"retryInterval"] ? [options[@"retryInterval"] doubleValue] / 1000.0 : 5.0;
99
+ NSString *newPosition =
100
+ options[@"position"] ? options[@"position"] : self.currentPosition;
101
+
102
+ BOOL newIsOverlapping =
103
+ options[@"isOverlapping"] ? [options[@"isOverlapping"] boolValue] : YES;
104
+ BOOL newIsAutoShow =
105
+ options[@"isAutoShow"] ? [options[@"isAutoShow"] boolValue] : YES;
106
+ BOOL newIsCollapsible =
107
+ options[@"collapsible"] ? [options[@"collapsible"] boolValue] : NO;
108
+ NSTimeInterval newMinLoadInterval =
109
+ options[@"retryInterval"]
110
+ ? [options[@"retryInterval"] doubleValue] / 1000.0
111
+ : 5.0;
96
112
 
97
113
  if (!adUnitId) {
98
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"adUnitId is required."];
99
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
114
+ CDVPluginResult *pluginResult =
115
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
116
+ messageAsString:@"adUnitId is required."];
117
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
118
+ callbackId:command.callbackId];
100
119
  return;
101
120
  }
102
121
 
103
122
  dispatch_async(dispatch_get_main_queue(), ^{
104
- NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970];
105
-
106
- if (self.isLoading) {
107
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Banner loading"];
108
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
109
- return;
110
- }
111
-
112
- BOOL isSameId = [self.lastAdUnitId isEqualToString:adUnitId];
113
- BOOL isSameSize = [self.lastSizeStr isEqualToString:requestedSize];
114
-
115
- self.isOverlapping = newIsOverlapping;
116
- self.isAutoShow = newIsAutoShow;
117
- self.isCollapsible = newIsCollapsible;
118
- self.minLoadInterval = newMinLoadInterval;
119
- self.currentPosition = newPosition;
120
-
121
- if (self.bannerView != nil && isSameId && isSameSize) {
122
- if (self.isAutoShow) {
123
- [self showBannerInternal];
124
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Banner Updated (Cached)"];
125
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
126
- } else {
127
- [self hideBannerInternal];
128
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Banner Hidden (Cached)"];
129
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
130
- }
131
- [self sendLoadedEvent:self.lastAdSize isCollapsible:self.isCollapsible isRefresh:NO];
132
- return;
133
- }
134
-
135
- if ((currentTime - self.lastLoadTime) < self.minLoadInterval) {
136
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Request too fast."];
137
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
138
- return;
139
- }
140
-
141
- self.lastPosition = self.currentPosition;
142
- [self loadBanner:adUnitId size:requestedSize command:command];
123
+ NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970];
124
+
125
+ if (self.isLoading) {
126
+ CDVPluginResult *pluginResult =
127
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
128
+ messageAsString:@"Banner loading"];
129
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
130
+ callbackId:command.callbackId];
131
+ return;
132
+ }
133
+
134
+ BOOL isSameId = [self.lastAdUnitId isEqualToString:adUnitId];
135
+ BOOL isSameSize = [self.lastSizeStr isEqualToString:requestedSize];
136
+
137
+ self.isOverlapping = newIsOverlapping;
138
+ self.isAutoShow = newIsAutoShow;
139
+ self.isCollapsible = newIsCollapsible;
140
+ self.minLoadInterval = newMinLoadInterval;
141
+ self.currentPosition = newPosition;
142
+
143
+ if (self.bannerView != nil && isSameId && isSameSize) {
144
+ if (self.isAutoShow) {
145
+ [self showBannerInternal];
146
+ CDVPluginResult *pluginResult =
147
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
148
+ messageAsString:@"Banner Updated (Cached)"];
149
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
150
+ callbackId:command.callbackId];
151
+ } else {
152
+ [self hideBannerInternal];
153
+ CDVPluginResult *pluginResult =
154
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
155
+ messageAsString:@"Banner Hidden (Cached)"];
156
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
157
+ callbackId:command.callbackId];
158
+ }
159
+ [self sendLoadedEvent:self.lastAdSize
160
+ isCollapsible:self.isCollapsible
161
+ isRefresh:NO];
162
+ return;
163
+ }
164
+
165
+ if ((currentTime - self.lastLoadTime) < self.minLoadInterval) {
166
+ NSString *errorMsg =
167
+ [NSString stringWithFormat:@"Request too fast. Please wait "
168
+ @"%.0fms to prevent invalid traffic.",
169
+ (self.minLoadInterval * 1000.0)];
170
+
171
+ CDVPluginResult *pluginResult =
172
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
173
+ messageAsString:errorMsg];
174
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
175
+ callbackId:command.callbackId];
176
+ return;
177
+ }
178
+
179
+ self.lastPosition = self.currentPosition;
180
+ [self loadBanner:adUnitId size:requestedSize command:command];
143
181
  });
144
182
  }
145
183
 
146
- - (void)loadBanner:(NSString *)adUnitId size:(NSString *)sizeStr command:(CDVInvokedUrlCommand *)command {
147
- [self destroyBannerInternal];
184
+ - (void)loadBanner:(NSString *)adUnitId
185
+ size:(NSString *)sizeStr
186
+ command:(CDVInvokedUrlCommand *)command {
148
187
 
149
188
  self.isLoading = YES;
150
189
  self.lastLoadTime = [[NSDate date] timeIntervalSince1970];
@@ -156,110 +195,131 @@
156
195
  GADAdSize adSize = [self getAdSize:sizeStr];
157
196
  self.lastAdSize = adSize;
158
197
 
159
- self.bannerView = [[GADBannerView alloc] initWithAdSize:adSize];
160
- self.bannerView.adUnitID = adUnitId;
161
- self.bannerView.rootViewController = rootViewController;
162
- self.bannerView.delegate = self;
163
-
164
- self.bannerView.hidden = YES;
198
+ GADBannerView *pendingView = [[GADBannerView alloc] initWithAdSize:adSize];
199
+ pendingView.adUnitID = adUnitId;
200
+ pendingView.rootViewController = rootViewController;
201
+ pendingView.delegate = self;
202
+ pendingView.hidden = YES;
165
203
 
166
204
  __weak typeof(self) weakSelf = self;
167
- self.bannerView.paidEventHandler = ^(GADAdValue * _Nonnull value) {
168
- NSString *jsonStr = [NSString stringWithFormat:@"{\"value\":%lld, \"currency\":\"%@\", \"precision\":%ld}",
169
- value.value.longLongValue, value.currencyCode, (long)value.precision];
170
- [weakSelf.plugin fireEvent:@"document" event:@"on.banner.revenue" withData:jsonStr];
205
+ pendingView.paidEventHandler = ^(GADAdValue *_Nonnull value) {
206
+ NSString *jsonStr = [NSString
207
+ stringWithFormat:
208
+ @"{\"value\":%lld, \"currency\":\"%@\", \"precision\":%ld}",
209
+ value.value.longLongValue, value.currencyCode,
210
+ (long)value.precision];
211
+ [weakSelf.plugin fireEvent:@"document"
212
+ event:@"on.banner.revenue"
213
+ withData:jsonStr];
171
214
  };
172
215
 
173
- [rootViewController.view addSubview:self.bannerView];
216
+ self.pendingBannerView = pendingView;
217
+ [rootViewController.view addSubview:self.pendingBannerView];
174
218
 
175
219
  GADRequest *request = [GADRequest request];
176
220
 
177
221
  if (self.isCollapsible) {
178
222
  GADExtras *extras = [[GADExtras alloc] init];
179
- NSString *anchor = [self.currentPosition isEqualToString:@"top"] ? @"top" : @"bottom";
180
- extras.additionalParameters = @{@"collapsible": anchor};
223
+ NSString *anchor =
224
+ [self.currentPosition isEqualToString:@"top"] ? @"top" : @"bottom";
225
+ extras.additionalParameters = @{@"collapsible" : anchor};
181
226
  [request registerAdNetworkExtras:extras];
182
227
  }
183
228
 
184
- [self.bannerView loadRequest:request];
229
+ [self.pendingBannerView loadRequest:request];
185
230
 
186
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Banner creation initiated."];
187
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
231
+ CDVPluginResult *pluginResult =
232
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
233
+ messageAsString:@"Banner creation initiated."];
234
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
235
+ callbackId:command.callbackId];
188
236
  }
189
237
 
190
238
  - (GADAdSize)getAdSize:(NSString *)sizeStr {
191
- if ([sizeStr isEqualToString:@"BANNER"]) return GADAdSizeBanner;
192
- if ([sizeStr isEqualToString:@"LARGE_BANNER"]) return GADAdSizeLargeBanner;
193
- if ([sizeStr isEqualToString:@"MEDIUM_RECTANGLE"]) return GADAdSizeMediumRectangle;
194
- if ([sizeStr isEqualToString:@"FULL_BANNER"]) return GADAdSizeFullBanner;
195
- if ([sizeStr isEqualToString:@"LEADERBOARD"]) return GADAdSizeLeaderboard;
239
+ if ([sizeStr isEqualToString:@"BANNER"])
240
+ return GADAdSizeBanner;
241
+ if ([sizeStr isEqualToString:@"LARGE_BANNER"])
242
+ return GADAdSizeLargeBanner;
243
+ if ([sizeStr isEqualToString:@"MEDIUM_RECTANGLE"])
244
+ return GADAdSizeMediumRectangle;
245
+ if ([sizeStr isEqualToString:@"FULL_BANNER"])
246
+ return GADAdSizeFullBanner;
247
+ if ([sizeStr isEqualToString:@"LEADERBOARD"])
248
+ return GADAdSizeLeaderboard;
196
249
 
197
250
  UIViewController *rootViewController = self.plugin.viewController;
198
251
  CGRect frame = rootViewController.view.frame;
199
252
  if (@available(iOS 11.0, *)) {
200
- frame = UIEdgeInsetsInsetRect(rootViewController.view.frame, rootViewController.view.safeAreaInsets);
253
+ frame = UIEdgeInsetsInsetRect(rootViewController.view.frame,
254
+ rootViewController.view.safeAreaInsets);
201
255
  }
202
- return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width);
256
+ return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(
257
+ frame.size.width);
203
258
  }
204
259
 
205
260
  - (void)layoutViews {
206
261
  dispatch_async(dispatch_get_main_queue(), ^{
207
- UIViewController *rootVC = self.plugin.viewController;
208
- UIView *webView = self.plugin.webView;
209
- if (!rootVC || !webView) return;
210
-
211
- UIWindow *window = [self getKeyWindow];
212
- UIEdgeInsets safeArea = (window) ? window.safeAreaInsets : UIEdgeInsetsZero;
213
-
214
- CGFloat screenH = UIScreen.mainScreen.bounds.size.height;
215
- CGFloat screenW = UIScreen.mainScreen.bounds.size.width;
216
-
217
- if (safeArea.bottom == 0 && screenH >= 812.0) safeArea.bottom = 34.0;
218
- if (safeArea.top == 0 && screenH >= 812.0) safeArea.top = 44.0;
219
-
220
- rootVC.view.backgroundColor = [UIColor blackColor];
221
- webView.superview.backgroundColor = [UIColor blackColor];
222
-
223
- CGRect fullScreenRect = CGRectMake(0, 0, screenW, screenH);
224
-
225
- if (self.isBannerVisible && self.bannerView && self.activeBannerHeight > 0) {
226
-
227
- CGSize adSize = self.bannerView.intrinsicContentSize;
228
- CGFloat bH = adSize.height > 0 ? adSize.height : self.activeBannerHeight;
229
- CGFloat bW = adSize.width > 0 ? adSize.width : self.bannerView.bounds.size.width;
230
- CGFloat bX = (screenW - bW) / 2.0;
231
- CGFloat bY = 0;
232
-
233
- if ([self.currentPosition isEqualToString:@"top"]) {
234
- bY = safeArea.top;
235
- } else {
236
- bY = screenH - safeArea.bottom - bH;
237
- }
238
-
239
- self.bannerView.frame = CGRectMake(bX, bY, bW, bH);
240
- self.bannerView.hidden = NO;
241
-
242
- if (!self.isOverlapping) {
243
- CGRect newWebFrame = fullScreenRect;
244
- if ([self.currentPosition isEqualToString:@"top"]) {
245
- newWebFrame.origin.y = bY + bH;
246
- newWebFrame.size.height = screenH - newWebFrame.origin.y;
247
- } else {
248
- newWebFrame.origin.y = 0;
249
- newWebFrame.size.height = bY;
250
- }
251
- webView.frame = newWebFrame;
252
- } else {
253
- webView.frame = fullScreenRect;
254
- }
255
- } else {
256
- if (self.bannerView) self.bannerView.hidden = YES;
257
- webView.frame = fullScreenRect;
258
- }
259
-
260
- if (self.bannerView && self.isBannerVisible) {
261
- [webView.superview bringSubviewToFront:self.bannerView];
262
- }
262
+ UIViewController *rootVC = self.plugin.viewController;
263
+ UIView *webView = self.plugin.webView;
264
+ if (!rootVC || !webView)
265
+ return;
266
+
267
+ UIWindow *window = [self getKeyWindow];
268
+ UIEdgeInsets safeArea =
269
+ (window) ? window.safeAreaInsets : UIEdgeInsetsZero;
270
+
271
+ CGFloat screenH = UIScreen.mainScreen.bounds.size.height;
272
+ CGFloat screenW = UIScreen.mainScreen.bounds.size.width;
273
+
274
+ if (safeArea.bottom == 0 && screenH >= 812.0)
275
+ safeArea.bottom = 34.0;
276
+ if (safeArea.top == 0 && screenH >= 812.0)
277
+ safeArea.top = 44.0;
278
+
279
+ CGRect fullScreenRect = CGRectMake(0, 0, screenW, screenH);
280
+
281
+ if (self.isBannerVisible && self.bannerView &&
282
+ self.activeBannerHeight > 0) {
283
+
284
+ CGSize adSize = self.bannerView.intrinsicContentSize;
285
+ CGFloat bH =
286
+ adSize.height > 0 ? adSize.height : self.activeBannerHeight;
287
+ CGFloat bW = adSize.width > 0 ? adSize.width
288
+ : self.bannerView.bounds.size.width;
289
+ CGFloat bX = (screenW - bW) / 2.0;
290
+ CGFloat bY = 0;
291
+
292
+ if ([self.currentPosition isEqualToString:@"top"]) {
293
+ bY = safeArea.top;
294
+ } else {
295
+ bY = screenH - safeArea.bottom - bH;
296
+ }
297
+
298
+ self.bannerView.frame = CGRectMake(bX, bY, bW, bH);
299
+ self.bannerView.hidden = NO;
300
+
301
+ if (!self.isOverlapping) {
302
+ CGRect newWebFrame = fullScreenRect;
303
+ if ([self.currentPosition isEqualToString:@"top"]) {
304
+ newWebFrame.origin.y = bY + bH;
305
+ newWebFrame.size.height = screenH - newWebFrame.origin.y;
306
+ } else {
307
+ newWebFrame.origin.y = 0;
308
+ newWebFrame.size.height = bY;
309
+ }
310
+ webView.frame = newWebFrame;
311
+ } else {
312
+ webView.frame = fullScreenRect;
313
+ }
314
+ } else {
315
+ if (self.bannerView)
316
+ self.bannerView.hidden = YES;
317
+ webView.frame = fullScreenRect;
318
+ }
319
+
320
+ if (self.bannerView && self.isBannerVisible) {
321
+ [webView.superview bringSubviewToFront:self.bannerView];
322
+ }
263
323
  });
264
324
  }
265
325
 
@@ -294,76 +354,131 @@
294
354
 
295
355
  - (void)showBanner:(CDVInvokedUrlCommand *)command {
296
356
  dispatch_async(dispatch_get_main_queue(), ^{
297
- if (self.bannerView) {
298
- [self showBannerInternal];
299
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
300
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
301
- } else {
302
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"No banner loaded"];
303
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
304
- }
357
+ if (self.bannerView) {
358
+ [self showBannerInternal];
359
+ CDVPluginResult *pluginResult =
360
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
361
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
362
+ callbackId:command.callbackId];
363
+ } else {
364
+ CDVPluginResult *pluginResult =
365
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
366
+ messageAsString:@"No banner loaded"];
367
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
368
+ callbackId:command.callbackId];
369
+ }
305
370
  });
306
371
  }
307
372
 
308
373
  - (void)hideBanner:(CDVInvokedUrlCommand *)command {
309
374
  dispatch_async(dispatch_get_main_queue(), ^{
310
- [self hideBannerInternal];
311
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
312
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
375
+ [self hideBannerInternal];
376
+ CDVPluginResult *pluginResult =
377
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
378
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
379
+ callbackId:command.callbackId];
313
380
  });
314
381
  }
315
382
 
316
383
  - (void)removeBanner:(CDVInvokedUrlCommand *)command {
317
384
  dispatch_async(dispatch_get_main_queue(), ^{
318
- [self destroyBannerInternal];
319
- self.lastAdUnitId = @"";
320
- self.lastSizeStr = @"";
321
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
322
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
385
+ [self destroyBannerInternal];
386
+ self.lastAdUnitId = @"";
387
+ self.lastSizeStr = @"";
388
+ CDVPluginResult *pluginResult =
389
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
390
+ [self.plugin.commandDelegate sendPluginResult:pluginResult
391
+ callbackId:command.callbackId];
323
392
  });
324
393
  }
325
394
 
326
395
  #pragma mark - Helper Events
327
396
 
328
- - (void)sendLoadedEvent:(GADAdSize)adSize isCollapsible:(BOOL)isCollapsible isRefresh:(BOOL)isRefresh {
329
- NSString *jsonStr = [NSString stringWithFormat:@"{\"width\":%f, \"height\":%f, \"isCollapsible\":%s}",
330
- adSize.size.width, adSize.size.height, isCollapsible ? "true" : "false"];
397
+ - (void)sendLoadedEvent:(GADAdSize)adSize
398
+ isCollapsible:(BOOL)isCollapsible
399
+ isRefresh:(BOOL)isRefresh {
400
+ NSString *jsonStr = [NSString
401
+ stringWithFormat:@"{\"width\":%f, \"height\":%f, \"isCollapsible\":%s}",
402
+ adSize.size.width, adSize.size.height,
403
+ isCollapsible ? "true" : "false"];
331
404
 
332
405
  if (isRefresh) {
333
- [self.plugin fireEvent:@"document" event:@"on.banner.refreshed" withData:nil];
406
+ [self.plugin fireEvent:@"document"
407
+ event:@"on.banner.refreshed"
408
+ withData:nil];
334
409
  } else {
335
- [self.plugin fireEvent:@"document" event:@"on.banner.load" withData:jsonStr];
410
+ [self.plugin fireEvent:@"document"
411
+ event:@"on.banner.load"
412
+ withData:jsonStr];
336
413
  }
337
414
  }
338
415
 
339
416
  #pragma mark - GADBannerViewDelegate
340
417
 
341
- - (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
342
- BOOL isRefresh = !self.isLoading;
343
- self.isLoading = NO;
418
+ - (void)bannerViewDidReceiveAd:(GADBannerView *)incomingBannerView {
419
+ if (incomingBannerView == self.pendingBannerView) {
420
+ self.isLoading = NO;
344
421
 
345
- self.activeBannerHeight = bannerView.adSize.size.height;
346
- if (self.activeBannerHeight == 0) {
347
- self.activeBannerHeight = self.lastAdSize.size.height;
348
- }
422
+ [self.bannerView removeFromSuperview];
423
+ self.bannerView.delegate = nil;
349
424
 
350
- [self sendLoadedEvent:self.lastAdSize isCollapsible:self.isCollapsible isRefresh:isRefresh];
425
+ self.bannerView = self.pendingBannerView;
426
+ self.pendingBannerView = nil;
427
+
428
+ self.activeBannerHeight = incomingBannerView.adSize.size.height;
429
+ if (self.activeBannerHeight == 0) {
430
+ self.activeBannerHeight = self.lastAdSize.size.height;
431
+ }
432
+
433
+ [self sendLoadedEvent:self.lastAdSize
434
+ isCollapsible:self.isCollapsible
435
+ isRefresh:NO];
436
+
437
+ if (self.isAutoShow && !self.isBannerVisible) {
438
+ [self showBannerInternal];
439
+ } else {
440
+ [self layoutViews];
441
+ }
442
+ } else if (incomingBannerView == self.bannerView) {
443
+
444
+ [self sendLoadedEvent:incomingBannerView.adSize
445
+ isCollapsible:self.isCollapsible
446
+ isRefresh:YES];
351
447
 
352
- if (self.isAutoShow && !self.isBannerVisible) {
353
- [self showBannerInternal];
354
- } else {
355
448
  [self layoutViews];
356
449
  }
357
450
  }
358
451
 
359
- - (void)bannerView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error {
360
- self.isLoading = NO;
361
- NSString *jsonStr = [NSString stringWithFormat:@"{\"code\":%ld, \"message\":\"%@\"}", (long)error.code, [error localizedDescription]];
362
- [self.plugin fireEvent:@"document" event:@"on.banner.failed" withData:jsonStr];
452
+ - (void)bannerView:(GADBannerView *)incomingBannerView
453
+ didFailToReceiveAdWithError:(NSError *)error {
454
+ if (incomingBannerView == self.pendingBannerView) {
455
+ self.isLoading = NO;
456
+
457
+ [incomingBannerView removeFromSuperview];
458
+ incomingBannerView.delegate = nil;
459
+ self.pendingBannerView = nil;
460
+
461
+ NSString *jsonStr = [NSString
462
+ stringWithFormat:@"{\"code\":%ld, \"message\":\"%@\"}",
463
+ (long)error.code, [error localizedDescription]];
464
+ [self.plugin fireEvent:@"document"
465
+ event:@"on.banner.failed"
466
+ withData:jsonStr];
467
+ } else if (incomingBannerView == self.bannerView) {
468
+
469
+ NSString *jsonStr = [NSString
470
+ stringWithFormat:@"{\"code\":%ld, \"message\":\"%@\"}",
471
+ (long)error.code, [error localizedDescription]];
472
+ [self.plugin fireEvent:@"document"
473
+ event:@"on.banner.failedToRefresh"
474
+ withData:jsonStr];
475
+ }
363
476
  }
364
477
 
365
478
  - (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
366
- [self.plugin fireEvent:@"document" event:@"on.banner.impression" withData:nil];
479
+ [self.plugin fireEvent:@"document"
480
+ event:@"on.banner.impression"
481
+ withData:nil];
367
482
  }
368
483
 
369
484
  - (void)bannerViewDidRecordClick:(GADBannerView *)bannerView {
@@ -67,6 +67,10 @@
67
67
 
68
68
  if ((currentTime - self.lastLoadTime) < self.minLoadInterval) {
69
69
 
70
+ NSString *errorMsg = [NSString stringWithFormat:@"Request too fast. Please wait %.0fms to prevent invalid traffic.", (self.minLoadInterval * 1000.0)];
71
+
72
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMsg];
73
+ [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
70
74
  return;
71
75
  }
72
76
 
@@ -85,7 +89,6 @@
85
89
  self.isLoading = NO;
86
90
 
87
91
  if (error) {
88
- self.interstitialAd = nil;
89
92
 
90
93
  NSString *jsonStr = [NSString stringWithFormat:@"{\"code\":%ld, \"message\":\"%@\"}", (long)error.code, [error localizedDescription]];
91
94
  [self.plugin fireEvent:@"document" event:@"on.interstitial.failed.load" withData:jsonStr];
@@ -69,6 +69,10 @@
69
69
 
70
70
  if ((currentTime - self.lastLoadTime) < self.minLoadInterval) {
71
71
 
72
+ NSString *errorMsg = [NSString stringWithFormat:@"Request too fast. Please wait %.0fms to prevent invalid traffic.", (self.minLoadInterval * 1000.0)];
73
+
74
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMsg];
75
+ [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
72
76
  return;
73
77
  }
74
78
 
@@ -87,7 +91,6 @@
87
91
  self.isLoading = NO;
88
92
 
89
93
  if (error) {
90
- self.rewardedAd = nil;
91
94
 
92
95
  NSString *jsonStr = [NSString stringWithFormat:@"{\"code\":%ld, \"message\":\"%@\"}", (long)error.code, [error localizedDescription]];
93
96
  [self.plugin fireEvent:@"document" event:@"on.rewarded.failed.load" withData:jsonStr];
@@ -77,10 +77,10 @@
77
77
 
78
78
  if ((currentTime - self.lastLoadTime) < self.minLoadInterval) {
79
79
 
80
- if (command) {
81
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Request too fast"];
82
- [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
83
- }
80
+ NSString *errorMsg = [NSString stringWithFormat:@"Request too fast. Please wait %.0fms to prevent invalid traffic.", (self.minLoadInterval * 1000.0)];
81
+
82
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMsg];
83
+ [self.plugin.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
84
84
  return;
85
85
  }
86
86
 
@@ -101,7 +101,6 @@
101
101
  self.isLoading = NO;
102
102
 
103
103
  if (error) {
104
- self.rewardedInterstitialAd = nil;
105
104
 
106
105
  NSString *jsonStr = [NSString stringWithFormat:@"{\"code\":%ld, \"message\":\"%@\"}", (long)error.code, [error localizedDescription]];
107
106
  [self.plugin fireEvent:@"document" event:@"on.rewardedInter.failed.load" withData:jsonStr];