emi-indo-cordova-plugin-admob 2.1.9 → 2.3.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/.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: emiindo
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']
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ IMPORTANT: PLEASE READ
12
+
13
+ WARNING: Failure to follow the issue template guidelines below will result in the issue being immediately closed.
14
+ -->
15
+
16
+ <!-- Fill out the relevant sections below and delete irrelevant sections. -->
17
+
18
+ # Bug report
19
+
20
+ <!-- COMPLETE THIS CHECKLIST -->
21
+
22
+
23
+ - [ ] I confirm this is a suspected bug or issue that will affect other users
24
+ <!-- i.e. this is not a request for support in using/integrating the plugin into your specific project -->
25
+
26
+ - [ ] I have reproduced the issue using the [example project](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/example/index.html) or provided the necessary information to reproduce the issue.
27
+ <!-- necessary information e.g. exact steps, FCM notification message content, test case project repo -->
28
+
29
+ - [ ] I have read [the documentation](https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/blob/main/README.md) thoroughly and it does not help solve my issue.
30
+ <!-- e.g. if you're having a build issue ensure you've read through the build environment notes -->
31
+
32
+ - [ ] I have checked that no similar issues (open or closed) already exist.
33
+ <!-- Duplicates or near-duplicates will be closed immediately. -->
34
+
35
+
36
+
37
+ **Current behavior:**
38
+
39
+ <!-- Describe how the bug manifests. -->
40
+
41
+ <!-- Explain how you're sure there is an issue with this plugin rather than your own code:
42
+ - If this plugin has an example project, have you been able to reproduce the issue within it?
43
+ - Have you created a clean test Cordova project containing only this plugin to eliminate the potential for interference with other plugins/code?
44
+ -->
45
+
46
+ **Expected behavior:**
47
+ <!-- Describe what the behavior should be without the bug. -->
48
+
49
+ **Steps to reproduce:**
50
+ <!-- If you are able to illustrate the bug with an example, please provide steps to reproduce. -->
51
+
52
+ **Screenshots**
53
+ <!-- If applicable, add screenshots to help explain your problem. -->
54
+
55
+ **Environment information**
56
+ <!-- Please supply full details of your development environment including: -->
57
+ - Plugin version
58
+ - `Plugin version: xxxx`
59
+
60
+ - Cordova CLI version
61
+ - `cordova -v`
62
+ - Cordova platform version
63
+ - `cordova platform ls`
64
+ - Plugins & versions installed in project (including this plugin)
65
+ - `cordova plugin ls`
66
+ - Dev machine OS and version, e.g.
67
+ - OSX
68
+ - `sw_vers`
69
+ - Windows 10
70
+ - `winver`
71
+
72
+ _Runtime issue_
73
+ - Device details
74
+ - _e.g. iPhone X, Samsung Galaxy S8, iPhone X Simulator, Pixel XL Emulator_
75
+ - OS details
76
+ - _e.g. iOS 12.2, Android 9.0_
77
+
78
+ _Android build issue:_
79
+ - Node JS version
80
+ - `node -v`
81
+ - Gradle version
82
+ - `ls platforms/android/.gradle`
83
+ - Target Android SDK version
84
+ - `android:targetSdkVersion` in `AndroidManifest.xml`
85
+ - Android SDK details
86
+ - `sdkmanager --list | sed -e '/Available Packages/q'`
87
+
88
+ _iOS build issue:_
89
+ - Node JS version
90
+ - `node -v`
91
+ - XCode version
92
+
93
+
94
+ **Related code:**
95
+ ```
96
+ insert any relevant code here such as plugin API calls / input parameters
97
+ ```
98
+
99
+ **Console output**
100
+ <details>
101
+ <summary>console output</summary>
102
+
103
+ ```
104
+
105
+ // Paste any relevant JS/native console output here
106
+
107
+ ```
108
+
109
+ </details><br/><br/>
110
+
111
+ **Other information:**
112
+
113
+ <!-- List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. -->
114
+
115
+
116
+
117
+
118
+
119
+ <!--
120
+ A POLITE REMINDER
121
+
122
+ - This is free, open-source software.
123
+ - Although the author makes every effort to maintain it, no guarantees are made as to the quality or reliability, and reported issues will be addressed if and when the author has time.
124
+ - Help/support will not be given by the author, so forums (e.g. Ionic) or Stack Overflow should be used. Any issues requesting help/support will be closed immediately.
125
+ - If you have urgent need of a bug fix/feature, the author can be engaged for PAID contract work to do so: please contact dave@workingedge.co.uk
126
+ - Rude or abusive comments/issues will not be tolerated, nor will opening multiple issues if those previously closed are deemed unsuitable. Any of the above will result in you being BANNED from ALL of my Github repositories.
127
+ -->
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ### emi-indo-cordova-plugin-admob@2.1.9
1
+ ### emi-indo-cordova-plugin-admob@2.3.9
2
2
 
3
3
 
4
4
  ## Features/method
@@ -159,7 +159,7 @@ config.xml
159
159
  ### Mobile Ads SDK (Android: 24.2.0) [Release Notes:](https://developers.google.com/admob/android/rel-notes)
160
160
  ### User Messaging Platform (UMP Android: 3.2.0) [Release Notes:](https://developers.google.com/admob/android/privacy/release-notes)
161
161
 
162
- ### Mobile Ads SDK (IOS: 12.2.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
162
+ ### Mobile Ads SDK (IOS: 12.5.0) [Release Notes:](https://developers.google.com/admob/ios/rel-notes)
163
163
 
164
164
  ### User Messaging Platform (UMP IOS: 3.0.0) [Release Notes:](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/privacy/download)
165
165
  ### IAB Europe Transparency & Consent Framework (CMP: 2.2.0)
@@ -14,7 +14,7 @@
14
14
  "author": "Apache Cordova Team",
15
15
  "license": "Apache-2.0",
16
16
  "devDependencies": {
17
- "emi-indo-cordova-plugin-admob": "^2.0.8"
17
+ "emi-indo-cordova-plugin-admob": "^2.2.9"
18
18
  },
19
19
  "cordova": {
20
20
  "plugins": {
@@ -8,16 +8,6 @@
8
8
 
9
9
  function loadBanner() {
10
10
 
11
- // Optional Only IOS
12
- if (isPlatformIOS){
13
- cordova.plugins.emiAdmobPlugin.styleBannerAd({
14
- isOverlapping: true, // default false
15
- paddingWebView: 1.0
16
- });
17
-
18
- }
19
-
20
-
21
11
  // default: Android | IOS
22
12
  cordova.plugins.emiAdmobPlugin.loadBannerAd({
23
13
  adUnitId: Banner_ID, //Banner_ID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emi-indo-cordova-plugin-admob",
3
- "version": "2.1.9",
3
+ "version": "2.3.9",
4
4
  "description": "Cordova/Quasar/Capacitor Plugin Admob Android IOS",
5
5
  "cordova": {
6
6
  "id": "emi-indo-cordova-plugin-admob",
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="2.1.9">
3
+ id="emi-indo-cordova-plugin-admob" version="2.3.9">
4
4
 
5
5
  <name>emiAdmobPlugin</name>
6
6
  <description>Cordova/Quasar/Capacitor Plugin Admob Android IOS</description>
@@ -298,9 +298,9 @@
298
298
  <source url="https://cdn.cocoapods.org/" />
299
299
  </config>
300
300
  <pods use-frameworks="true">
301
- <!--minimum macOS 14.4 > Xcode 16.0 -->
301
+ <!--minimum macOS 14.4 > Xcode 16.0 -->
302
302
  <pod name="GoogleUserMessagingPlatform" spec="~> 3.0.0" />
303
- <pod name="Google-Mobile-Ads-SDK" spec="~> 12.2.0" />
303
+ <pod name="Google-Mobile-Ads-SDK" spec="~> 12.5.0" />
304
304
 
305
305
  </pods>
306
306
  </podspec>
@@ -262,7 +262,7 @@ class emiAdmobPlugin : CordovaPlugin() {
262
262
  if (consentInformation!!.canRequestAds()) {
263
263
  initializeMobileAdsSdk()
264
264
  }
265
- cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed', { message: '" + formError.message + "' });")
265
+ cWebView!!.loadUrl("javascript:cordova.fireDocumentEvent('on.consent.info.update.failed', ${formError.message});")
266
266
  })
267
267
  }
268
268
  if (consentInformation?.canRequestAds()!!) {
@@ -16,9 +16,17 @@
16
16
  @property(nonatomic, readonly) BOOL canRequestAds;
17
17
  @property (nonatomic, assign) BOOL isUsingAdManagerRequest;
18
18
  @property (nonatomic, assign) CGFloat viewWidth;
19
+ @property(nonatomic, assign) BOOL isOverlapping;
20
+ @property(nonatomic, assign) BOOL isCollapsible;
21
+ @property(nonatomic, assign) BOOL isBannerOpen;
19
22
  @property (nonatomic, strong) UIView *bannerViewLayout;
20
23
  @property (nonatomic, strong) UIView *bannerContainer;
21
24
  @property (nonatomic, strong) UIView *webViewContainer;
25
+ @property(nonatomic, assign) BOOL isAutoShowAppOpen;
26
+ @property(nonatomic, assign) BOOL isAutoShowBanner;
27
+ @property(nonatomic, assign) BOOL isAutoShowInterstitial;
28
+ @property(nonatomic, assign) BOOL isAutoShowRewardedAds;
29
+ @property(nonatomic, assign) BOOL isAutoShowRewardedInt;
22
30
 
23
31
  - (void)initialize:(CDVInvokedUrlCommand *)command;
24
32
  - (void)requestIDFA:(CDVInvokedUrlCommand *)command;
@@ -7,6 +7,7 @@
7
7
  #import <Cordova/CDVViewController.h>
8
8
 
9
9
  @implementation emiAdmobPlugin
10
+
10
11
  @synthesize appOpenAd;
11
12
  @synthesize bannerView;
12
13
  @synthesize interstitial;
@@ -15,25 +16,20 @@
15
16
  @synthesize command;
16
17
  @synthesize responseInfo;
17
18
  @synthesize isPrivacyOptionsRequired;
19
+
18
20
  int attStatus = 0;
19
- // int fromStatus = 0; // Deprecated
21
+
20
22
  int Consent_Status = 0;
21
23
  int adFormat = 0;
22
24
  int adWidth = 320; // Default
23
25
 
24
- BOOL auto_Show = NO;
25
26
  // NSString *Npa = @"1"; // Deprecated
26
27
  NSString *setPosition = @"bottom-center"; // Default
27
28
  NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
28
29
 
29
-
30
-
31
- BOOL isCollapsible = NO;
32
30
  BOOL isAutoResize = NO;
33
31
 
34
-
35
32
  CGFloat paddingWebView = 0; // Default
36
- BOOL isSetOverlapping = NO; // Default
37
33
  CGFloat bannerHeightFinal = 50; // Default
38
34
 
39
35
  int isAdSkip = 0;
@@ -60,10 +56,10 @@ NSString *setKeyword = @"";
60
56
  - (void)setAdRequest {
61
57
  if (isUsingAdManagerRequest) {
62
58
  self.globalRequest = [GAMRequest request];
63
- NSLog(@"Using AdManager request");
59
+ // NSLog(@"Using AdManager request");
64
60
  } else {
65
61
  self.globalRequest = [GADRequest request];
66
- NSLog(@"Using AdMob request");
62
+ // NSLog(@"Using AdMob request");
67
63
  }
68
64
 
69
65
  if (isEnabledKeyword && setKeyword.length > 0) {
@@ -71,7 +67,7 @@ NSString *setKeyword = @"";
71
67
  for (NSString *keyword in keywords) {
72
68
  NSString *trimmedKeyword = [keyword stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
73
69
  if (trimmedKeyword.length > 0) {
74
- NSLog(@"Adding keyword: %@", trimmedKeyword);
70
+ // NSLog(@"Adding keyword: %@", trimmedKeyword);
75
71
  [self.globalRequest setKeywords:[self.globalRequest.keywords arrayByAddingObject:trimmedKeyword]];
76
72
  }
77
73
  }
@@ -81,17 +77,9 @@ NSString *setKeyword = @"";
81
77
 
82
78
 
83
79
 
80
+ - (void)isResponseInfo:(BOOL)value { isResponseInfo = value; }
81
+ - (void)isDebugGeography:(BOOL)value { isDebugGeography = value; }
84
82
 
85
-
86
-
87
-
88
-
89
- - (void)isResponseInfo:(BOOL)value {
90
- isResponseInfo = value;
91
- }
92
- - (void)isDebugGeography:(BOOL)value {
93
- isDebugGeography = value;
94
- }
95
83
  - (void)initialize:(CDVInvokedUrlCommand *)command {
96
84
 
97
85
  NSDictionary *options = [command.arguments objectAtIndex:0];
@@ -154,11 +142,11 @@ NSString *setKeyword = @"";
154
142
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
155
143
  }];
156
144
  }
157
-
158
145
 
159
146
  if (UMPConsentInformation.sharedInstance.canRequestAds) {
160
147
  [self startGoogleMobileAdsSDK];
161
148
  }
149
+
162
150
  }];
163
151
  } else if (status == UMPConsentStatusNotRequired || status == UMPConsentStatusObtained) {
164
152
  if (UMPConsentInformation.sharedInstance.canRequestAds) {
@@ -183,8 +171,6 @@ NSString *setKeyword = @"";
183
171
 
184
172
  if (@available(iOS 14, *)) {
185
173
  dispatch_async(dispatch_get_main_queue(), ^{
186
- // Added a 1-second pause before performing a tracking authorization request
187
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
188
174
 
189
175
  [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
190
176
  if (status == ATTrackingManagerAuthorizationStatusDenied) {
@@ -200,7 +186,6 @@ NSString *setKeyword = @"";
200
186
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:attStatus];
201
187
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
202
188
  }];
203
- });
204
189
  });
205
190
  } else {
206
191
  [self fireEvent:@"" event:@"on.getIDFA.error" withData:nil];
@@ -254,26 +239,15 @@ NSString *setKeyword = @"";
254
239
  result[@"TCString"] = TCString;
255
240
  result[@"additionalConsent"] = additionalConsent;
256
241
 
257
- // NSLog(@"Result dictionary: %@", result);consentStatus
258
-
259
242
  NSError *error;
260
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result
261
- options:0
262
- error:&error];
243
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result options:0 error:&error];
263
244
 
264
245
  if (!jsonData) {
265
- NSLog(@"Error converting result to JSON: %@",
266
- error.localizedDescription);
246
+ NSLog(@"Error converting result to JSON: %@", error.localizedDescription);
267
247
  } else {
268
- NSString *jsonString =
269
- [[NSString alloc] initWithData:jsonData
270
- encoding:NSUTF8StringEncoding];
271
-
272
- // NSLog(@"JSON String: %@", jsonString);
273
-
248
+ NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
274
249
  [self fireEvent:@"" event:@"on.sdkInitialization" withData:jsonString];
275
250
  }
276
-
277
251
  [prefs synchronize];
278
252
  }];
279
253
  });
@@ -316,6 +290,8 @@ NSString *setKeyword = @"";
316
290
  });
317
291
  }
318
292
 
293
+
294
+
319
295
  - (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command {
320
296
  NSString *deviceId = [self __getAdMobDeviceId];
321
297
  UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
@@ -370,10 +346,6 @@ NSString *setKeyword = @"";
370
346
 
371
347
 
372
348
 
373
-
374
-
375
-
376
-
377
349
  - (BOOL)isPrivacyOptionsRequired {
378
350
  UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
379
351
 
@@ -399,10 +371,8 @@ NSString *setKeyword = @"";
399
371
  }
400
372
 
401
373
  CDVPluginResult *pluginResult =
402
- [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
403
- messageAsInt:Consent_Status];
404
- [self.commandDelegate sendPluginResult:pluginResult
405
- callbackId:command.callbackId];
374
+ [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:Consent_Status];
375
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
406
376
  }];
407
377
  }
408
378
 
@@ -462,8 +432,7 @@ NSString *setKeyword = @"";
462
432
  setPublisherFirstPartyIDEnabled:pubIdEnabled];
463
433
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
464
434
  } @catch (NSException *exception) {
465
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
466
- messageAsString:exception.reason];
435
+ pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
467
436
  }
468
437
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
469
438
  }
@@ -531,14 +500,13 @@ NSString *setKeyword = @"";
531
500
  result[@"IABTCF_PurposeConsents"] = PurposeConsents;
532
501
  result[@"IABTCF_TCString"] = TCString;
533
502
 
534
- // NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
535
-
536
503
  [prefs synchronize];
537
504
  }
538
505
 
539
506
 
507
+
540
508
  - (void)orientationDidChange:(NSNotification *)notification {
541
- // NSLog(@"Orientation changed");
509
+ /*
542
510
  [self fireEvent:@"" event:@"on.screen.rotated" withData:nil];
543
511
  if (isAutoResize) {
544
512
  dispatch_async(dispatch_get_main_queue(), ^{
@@ -584,24 +552,22 @@ NSString *setKeyword = @"";
584
552
 
585
553
  [self.bannerViewLayout addSubview:self.bannerView];
586
554
  [self.bannerViewLayout bringSubviewToFront:self.bannerView];
587
-
588
- if (isSetOverlapping) {
589
-
590
- if (auto_Show && self.bannerView) {
591
- if (isSetOverlapping){
555
+
556
+ if (self.isAutoShowBanner && self.bannerView) {
557
+ if (!self.isOverlapping){
592
558
  self.bannerView.hidden = NO;
593
559
  [self setBodyHeight:self.command];
594
- }
560
+ } else {
561
+ self.bannerView.hidden = NO;
562
+ }
595
563
  }
596
564
 
597
-
598
- }
599
-
600
565
  } @catch (NSException *exception) {
601
566
  NSLog(@"Exception: %@", exception.reason);
602
567
  }
603
568
  });
604
569
  }
570
+ */
605
571
  }
606
572
 
607
573
 
@@ -615,12 +581,11 @@ NSString *setKeyword = @"";
615
581
  NSString *collapsible = [options valueForKey:@"collapsible"];
616
582
  BOOL autoResize = [[options valueForKey:@"autoResize"] boolValue];
617
583
  NSString *size = [options valueForKey:@"size"];
618
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
584
+ self.isAutoShowBanner = [[options valueForKey:@"autoShow"] boolValue];
585
+ self.isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
619
586
 
620
587
  bannerSaveAdUnitId = adUnitId;
621
-
622
588
  setPosition = position;
623
-
624
589
  adFormat = 5;
625
590
 
626
591
  if (adUnitId == nil || [adUnitId length] == 0) {
@@ -630,10 +595,10 @@ NSString *setKeyword = @"";
630
595
  return;
631
596
  }
632
597
 
633
- if (collapsible != nil && [collapsible length] > 0) {
634
- isCollapsible = YES;
598
+ if (collapsible != nil && [collapsible length] > 0) {
599
+ self.isCollapsible = YES;
635
600
  } else {
636
- isCollapsible = NO;
601
+ self.isCollapsible = NO;
637
602
  }
638
603
 
639
604
  if (autoResize) {
@@ -642,8 +607,10 @@ NSString *setKeyword = @"";
642
607
 
643
608
  [self setAdRequest];
644
609
 
645
- if (adFormat == 5) {
610
+ if (adFormat == 5 && !self.isBannerOpen) {
646
611
  dispatch_async(dispatch_get_main_queue(), ^{
612
+
613
+
647
614
  UIView *parentView = self.viewController.view;
648
615
  CGRect frame = self.bannerView.frame;
649
616
 
@@ -653,19 +620,16 @@ NSString *setKeyword = @"";
653
620
  }
654
621
 
655
622
  self.viewWidth = frame.size.width;
656
-
657
- auto_Show = autoShow;
623
+
658
624
  adWidth = self.viewWidth;
659
625
 
660
626
  GADAdSize siz = [self __AdSizeFromString:size];
661
627
  self.bannerView = [[GADBannerView alloc] initWithAdSize:siz];
662
628
 
663
-
664
629
  CGSize bannerSize = self.bannerView.bounds.size;
665
630
  CGFloat screenWidth = parentView.bounds.size.width;
666
631
  CGFloat screenHeight = parentView.bounds.size.height;
667
632
 
668
- // Default to top-center
669
633
  CGFloat originX = (screenWidth - bannerSize.width) / 2;
670
634
  CGFloat originY = 0;
671
635
 
@@ -680,9 +644,9 @@ NSString *setKeyword = @"";
680
644
 
681
645
  GADExtras *extras = [[GADExtras alloc] init];
682
646
 
683
- if (isCollapsible) {
647
+ if (self.isCollapsible) {
684
648
  extras.additionalParameters = @{@"collapsible" : collapsible};
685
-
649
+
686
650
  [self.globalRequest registerAdNetworkExtras:extras];
687
651
 
688
652
  }
@@ -700,7 +664,7 @@ NSString *setKeyword = @"";
700
664
 
701
665
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
702
666
  } else {
703
- // NSLog(@"Admob Option invalid for banner");
667
+
704
668
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
705
669
  }
706
670
 
@@ -710,15 +674,29 @@ NSString *setKeyword = @"";
710
674
 
711
675
  - (void)showBannerAd:(CDVInvokedUrlCommand *)command {
712
676
  @try {
713
- if (self.bannerView) {
714
- self.bannerView.hidden = NO;
715
- if (isSetOverlapping){
677
+
678
+ if (self.bannerView && self.isBannerOpen) {
679
+
680
+ if (!self.isOverlapping){
681
+ self.bannerView.hidden = NO;
716
682
  [self setBodyHeight:command];
683
+ } else {
684
+ self.bannerView.hidden = NO;
717
685
  }
718
-
686
+
687
+ } else if (self.bannerView && !self.isAutoShowBanner) {
688
+
689
+ if (!self.isOverlapping){
690
+ self.bannerView.hidden = NO;
691
+ [self setBodyHeight:command];
692
+ } else {
693
+ self.bannerView.hidden = NO;
694
+ }
695
+
719
696
  } else {
720
697
  [self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
721
698
  }
699
+
722
700
  }
723
701
  @catch (NSException *exception) {
724
702
  NSLog(@"[AdPlugin] Error in showBannerAd: %@", exception.reason);
@@ -742,105 +720,109 @@ NSString *setKeyword = @"";
742
720
 
743
721
 
744
722
  - (void)setBodyHeight:(CDVInvokedUrlCommand*)command {
745
- dispatch_async(dispatch_get_main_queue(), ^{
746
- @try {
747
-
748
- UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
749
- UIViewController* rootViewController = keyWindow.rootViewController;
750
-
751
- if (!rootViewController) {
752
- CDVPluginResult* errorResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Root ViewController not found"];
753
- [self.commandDelegate sendPluginResult:errorResult callbackId:command.callbackId];
754
- return;
755
- }
723
+ if(!self.isBannerOpen){
724
+ dispatch_async(dispatch_get_main_queue(), ^{
756
725
 
757
-
758
- [rootViewController.view setNeedsLayout];
759
- [rootViewController.view layoutIfNeeded];
760
-
761
- UIEdgeInsets safeAreaInsets = rootViewController.view.safeAreaInsets;
762
-
763
- if (safeAreaInsets.bottom == 0) {
764
- safeAreaInsets = keyWindow.safeAreaInsets;
765
- }
766
-
767
- CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
768
- CGFloat screenWidth = UIScreen.mainScreen.bounds.size.width;
769
- CGFloat bannerHeight = bannerHeightFinal;
770
- CGFloat newHeight = screenHeight - bannerHeight;
771
-
772
-
773
- if (newHeight <= 0) {
774
-
775
- CDVPluginResult* errorResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid new height"];
776
- [self.commandDelegate sendPluginResult:errorResult callbackId:command.callbackId];
777
- return;
778
- }
779
-
780
- UIView *webView = [self findWebViewInView:rootViewController.view];
781
- if (webView) {
782
- CGRect webViewFrame = webView.frame;
783
- webViewFrame.size.height = newHeight;
784
- webView.frame = webViewFrame;
785
- } else {
786
- NSLog(@"[CordovaBodyHeight] WebView not found");
787
- }
788
-
789
- if ([setPosition isEqualToString:@"top-center"]) {
790
- CGRect currentBannerFrame = self.bannerView.frame;
791
- CGFloat expectedYPosition = safeAreaInsets.top;
792
-
793
- if (fabs(currentBannerFrame.origin.y - expectedYPosition) > 0.1) {
794
- CGRect bannerFrame = CGRectMake(0, expectedYPosition, screenWidth, bannerHeight);
795
- self.bannerView.frame = bannerFrame;
796
- CGRect contentFrame = rootViewController.view.frame;
797
- contentFrame.origin.y = bannerHeight + safeAreaInsets.top;
798
- contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.top);
799
- rootViewController.view.frame = contentFrame;
800
- }
801
- } else if ([setPosition isEqualToString:@"bottom-center"]) {
802
-
803
- CGRect bannerFrame = CGRectMake(
804
- 0,
805
- screenHeight - bannerHeight - safeAreaInsets.bottom + paddingWebView,
806
- screenWidth,
807
- bannerHeight
808
- );
809
- self.bannerView.frame = bannerFrame;
810
-
811
- CGRect contentFrame = rootViewController.view.frame;
812
- contentFrame.origin.y = 0;
813
- contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.bottom);
814
- rootViewController.view.frame = contentFrame;
815
-
816
- } else {
817
- CGRect bannerFrame = CGRectMake(
818
- 0,
819
- screenHeight - bannerHeight - safeAreaInsets.bottom + paddingWebView,
820
- screenWidth,
821
- bannerHeight
822
- );
823
- self.bannerView.frame = bannerFrame;
824
-
825
- CGRect contentFrame = rootViewController.view.frame;
826
- contentFrame.origin.y = 0;
827
- contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.bottom);
828
- rootViewController.view.frame = contentFrame;
829
-
830
- }
831
-
726
+ @try {
727
+
728
+ UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
729
+ UIViewController* rootViewController = keyWindow.rootViewController;
730
+
731
+ if (!rootViewController) {
732
+ CDVPluginResult* errorResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Root ViewController not found"];
733
+ [self.commandDelegate sendPluginResult:errorResult callbackId:command.callbackId];
734
+ return;
735
+ }
736
+
737
+
738
+ [rootViewController.view setNeedsLayout];
739
+ [rootViewController.view layoutIfNeeded];
740
+
741
+ UIEdgeInsets safeAreaInsets = rootViewController.view.safeAreaInsets;
742
+
743
+ if (safeAreaInsets.bottom == 0) {
744
+ safeAreaInsets = keyWindow.safeAreaInsets;
745
+ }
746
+
747
+ CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
748
+ CGFloat screenWidth = UIScreen.mainScreen.bounds.size.width;
749
+ CGFloat bannerHeight = bannerHeightFinal;
750
+ CGFloat newHeight = screenHeight - bannerHeight;
751
+
752
+
753
+ if (newHeight <= 0) {
754
+
755
+ CDVPluginResult* errorResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid new height"];
756
+ [self.commandDelegate sendPluginResult:errorResult callbackId:command.callbackId];
757
+ return;
758
+ }
759
+
760
+ UIView *webView = [self findWebViewInView:rootViewController.view];
761
+ if (webView) {
762
+ CGRect webViewFrame = webView.frame;
763
+ webViewFrame.size.height = newHeight;
764
+ webView.frame = webViewFrame;
765
+ } else {
766
+ NSLog(@"[CordovaBodyHeight] WebView not found");
767
+ }
768
+
769
+ if ([setPosition isEqualToString:@"top-center"]) {
770
+ CGRect currentBannerFrame = self.bannerView.frame;
771
+ CGFloat expectedYPosition = safeAreaInsets.top;
772
+
773
+ if (fabs(currentBannerFrame.origin.y - expectedYPosition) > 0.1) {
774
+ CGRect bannerFrame = CGRectMake(0, expectedYPosition, screenWidth, bannerHeight);
775
+ self.bannerView.frame = bannerFrame;
776
+ CGRect contentFrame = rootViewController.view.frame;
777
+ contentFrame.origin.y = bannerHeight + safeAreaInsets.top;
778
+ contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.top);
779
+ rootViewController.view.frame = contentFrame;
780
+ }
781
+ } else if ([setPosition isEqualToString:@"bottom-center"]) {
782
+
783
+ CGRect bannerFrame = CGRectMake(
784
+ 0,
785
+ screenHeight - bannerHeight - safeAreaInsets.bottom + paddingWebView,
786
+ screenWidth,
787
+ bannerHeight
788
+ );
789
+ self.bannerView.frame = bannerFrame;
790
+
791
+ CGRect contentFrame = rootViewController.view.frame;
792
+ contentFrame.origin.y = 0;
793
+ contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.bottom);
794
+ rootViewController.view.frame = contentFrame;
795
+
796
+ } else {
797
+ CGRect bannerFrame = CGRectMake(
798
+ 0,
799
+ screenHeight - bannerHeight - safeAreaInsets.bottom + paddingWebView,
800
+ screenWidth,
801
+ bannerHeight
802
+ );
803
+ self.bannerView.frame = bannerFrame;
804
+
805
+ CGRect contentFrame = rootViewController.view.frame;
806
+ contentFrame.origin.y = 0;
807
+ contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.bottom);
808
+ rootViewController.view.frame = contentFrame;
809
+
810
+ }
811
+
832
812
  [self.bannerView setNeedsLayout];
833
813
  [self.bannerView layoutIfNeeded];
834
814
  [rootViewController.view setNeedsLayout];
835
815
  [rootViewController.view layoutIfNeeded];
836
-
837
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:newHeight];
838
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
839
- }
840
- @catch (NSException* exception) {
841
- NSLog(@"[CordovaBodyHeight] Exception: %@", exception.reason);
842
- }
843
- });
816
+
817
+ CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:newHeight];
818
+ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
819
+ }
820
+ @catch (NSException* exception) {
821
+ NSLog(@"[CordovaBodyHeight] Exception: %@", exception.reason);
822
+ }
823
+
824
+ });
825
+ }
844
826
  }
845
827
 
846
828
 
@@ -860,10 +842,9 @@ NSString *setKeyword = @"";
860
842
 
861
843
  - (void)styleBannerAd:(CDVInvokedUrlCommand *)command {
862
844
  NSDictionary *options = [command.arguments objectAtIndex:0];
863
- BOOL isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
845
+ self.isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
864
846
  CGFloat paddingContainer = [[options valueForKey:@"paddingWebView"] floatValue];
865
847
 
866
- isSetOverlapping = isOverlapping;
867
848
  paddingWebView = paddingContainer;
868
849
 
869
850
  dispatch_async(dispatch_get_main_queue(), ^{
@@ -990,7 +971,7 @@ NSString *setKeyword = @"";
990
971
  - (void)hideBannerAd:(CDVInvokedUrlCommand *)command {
991
972
  CDVPluginResult *pluginResult;
992
973
  NSString *callbackId = command.callbackId;
993
- if (self.bannerView) {
974
+ if (self.bannerView && self.isBannerOpen) {
994
975
  dispatch_async(dispatch_get_main_queue(), ^{
995
976
  self.bannerView.hidden = YES;
996
977
  [self resetWebViewHeight];
@@ -1012,6 +993,7 @@ NSString *setKeyword = @"";
1012
993
  dispatch_async(dispatch_get_main_queue(), ^{
1013
994
  self.bannerView.hidden = YES;
1014
995
  [self.bannerView removeFromSuperview];
996
+ self.isBannerOpen = NO;
1015
997
  self.bannerView = nil;
1016
998
  [self resetWebViewHeight];
1017
999
  [self fireEvent:@"" event:@"on.banner.remove" withData:nil];
@@ -1022,15 +1004,16 @@ NSString *setKeyword = @"";
1022
1004
  }
1023
1005
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
1024
1006
  }
1007
+
1008
+
1025
1009
  - (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command {
1026
1010
  CDVPluginResult *pluginResult;
1027
1011
  NSString *callbackId = command.callbackId;
1028
1012
 
1029
1013
  NSDictionary *options = [command.arguments objectAtIndex:0];
1030
1014
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
1031
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1015
+ self.isAutoShowAppOpen = [[options valueForKey:@"autoShow"] boolValue];
1032
1016
 
1033
- auto_Show = autoShow;
1034
1017
  adFormat = 1;
1035
1018
  self.appOpenAd = nil;
1036
1019
 
@@ -1084,7 +1067,7 @@ NSString *setKeyword = @"";
1084
1067
  };
1085
1068
 
1086
1069
 
1087
- if (auto_Show) {
1070
+ if (self.isAutoShowAppOpen) {
1088
1071
  NSError *presentError = nil;
1089
1072
  if ([self.appOpenAd canPresentFromRootViewController:self.viewController error:&presentError]) {
1090
1073
  [self.appOpenAd presentFromRootViewController:self.viewController];
@@ -1146,9 +1129,7 @@ NSString *setKeyword = @"";
1146
1129
  - (void)showAppOpenAd:(CDVInvokedUrlCommand *)command {
1147
1130
  CDVPluginResult *pluginResult;
1148
1131
  NSString *callbackId = command.callbackId;
1149
- if (self.appOpenAd &&
1150
- [self.appOpenAd canPresentFromRootViewController:self.viewController
1151
- error:nil]) {
1132
+ if (self.appOpenAd && [self.appOpenAd canPresentFromRootViewController:self.viewController error:nil]) {
1152
1133
  [self.appOpenAd presentFromRootViewController:self.viewController];
1153
1134
  adFormat = 1;
1154
1135
  pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
@@ -1158,15 +1139,16 @@ NSString *setKeyword = @"";
1158
1139
  }
1159
1140
  [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
1160
1141
  }
1142
+
1143
+
1161
1144
  - (void)loadInterstitialAd:(CDVInvokedUrlCommand *)command {
1162
1145
  CDVPluginResult *pluginResult;
1163
1146
  NSString *callbackId = command.callbackId;
1164
1147
 
1165
1148
  NSDictionary *options = [command.arguments objectAtIndex:0];
1166
1149
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
1167
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1150
+ self.isAutoShowInterstitial = [[options valueForKey:@"autoShow"] boolValue];
1168
1151
 
1169
- auto_Show = autoShow;
1170
1152
  adFormat = 2;
1171
1153
  [self setAdRequest];
1172
1154
  if (adFormat == 2) {
@@ -1213,7 +1195,7 @@ NSString *setKeyword = @"";
1213
1195
  };
1214
1196
 
1215
1197
 
1216
- if (auto_Show) {
1198
+ if (self.isAutoShowInterstitial) {
1217
1199
  NSError *presentError = nil;
1218
1200
  if ([self.interstitial canPresentFromRootViewController:self.viewController error:&presentError]) {
1219
1201
  [self.interstitial presentFromRootViewController:self.viewController];
@@ -1300,9 +1282,8 @@ NSString *setKeyword = @"";
1300
1282
 
1301
1283
  NSDictionary *options = [command.arguments objectAtIndex:0];
1302
1284
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
1303
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1285
+ self.isAutoShowRewardedInt = [[options valueForKey:@"autoShow"] boolValue];
1304
1286
 
1305
- auto_Show = autoShow;
1306
1287
  adFormat = 4;
1307
1288
  [self setAdRequest];
1308
1289
  if (adFormat == 4) {
@@ -1348,7 +1329,7 @@ NSString *setKeyword = @"";
1348
1329
  };
1349
1330
 
1350
1331
 
1351
- if (auto_Show) {
1332
+ if (self.isAutoShowRewardedInt) {
1352
1333
  NSError *presentError = nil;
1353
1334
  if ([self.rewardedInterstitialAd canPresentFromRootViewController:self.viewController error:&presentError]) {
1354
1335
  [self.rewardedInterstitialAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
@@ -1461,10 +1442,7 @@ NSString *setKeyword = @"";
1461
1442
  NSString *callbackId = command.callbackId;
1462
1443
  NSDictionary *options = [command.arguments objectAtIndex:0];
1463
1444
  NSString *adUnitId = [options valueForKey:@"adUnitId"];
1464
- BOOL autoShow = [[options valueForKey:@"autoShow"] boolValue];
1465
- //auto_Show = autoShow;
1466
-
1467
- __block BOOL shouldAutoShow = autoShow;
1445
+ self.isAutoShowRewardedAds = [[options valueForKey:@"autoShow"] boolValue];
1468
1446
 
1469
1447
  adFormat = 3;
1470
1448
  [self setAdRequest];
@@ -1509,7 +1487,7 @@ NSString *setKeyword = @"";
1509
1487
 
1510
1488
 
1511
1489
 
1512
- if (shouldAutoShow) {
1490
+ if (self.isAutoShowRewardedAds) {
1513
1491
  NSError *presentError = nil;
1514
1492
  if ([self.rewardedAd canPresentFromRootViewController:self.viewController error:&presentError]) {
1515
1493
  [self.rewardedAd presentFromRootViewController:self.viewController userDidEarnRewardHandler:^{
@@ -1712,7 +1690,7 @@ NSString *setKeyword = @"";
1712
1690
  #pragma mark GADBannerViewDelegate implementation
1713
1691
 
1714
1692
  - (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
1715
- // NSLog(@"The last loaded banner is %@collapsible.", (bannerView.isCollapsible ? @"" : @"not "));
1693
+
1716
1694
  NSString *collapsibleStatus = bannerView.isCollapsible ? @"collapsible" : @"not collapsible";
1717
1695
  NSDictionary *eventData = @{@"collapsible" : collapsibleStatus};
1718
1696
  NSError *error;
@@ -1723,26 +1701,24 @@ NSString *setKeyword = @"";
1723
1701
  [self fireEvent:@"" event:@"on.is.collapsible" withData:jsonString];
1724
1702
  }
1725
1703
 
1726
- // Get the banner height
1727
1704
  CGFloat bannerHeight = bannerView.bounds.size.height;
1728
1705
  bannerHeightFinal = bannerHeight;
1729
1706
 
1730
-
1731
- // Prepare height data for banner load event
1732
1707
  NSDictionary *bannerLoadData = @{@"height" : @(bannerHeight)};
1733
1708
  NSData *bannerLoadJsonData = [NSJSONSerialization dataWithJSONObject:bannerLoadData options:0 error:&error];
1734
1709
  NSString *bannerLoadJsonString = [[NSString alloc] initWithData:bannerLoadJsonData encoding:NSUTF8StringEncoding];
1735
1710
 
1736
- // Fire the banner load event with the height data
1737
1711
  [self fireEvent:@"" event:@"on.banner.load" withData:bannerLoadJsonString];
1712
+
1738
1713
 
1739
- if (auto_Show && self.bannerView) {
1740
- if (isSetOverlapping){
1741
- self.bannerView.hidden = NO;
1742
- [self setBodyHeight:command];
1743
- }
1744
- } else {
1745
- [self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
1714
+
1715
+ if (self.isAutoShowBanner && self.bannerView && !self.isBannerOpen) {
1716
+ if (!self.isOverlapping){
1717
+ self.bannerView.hidden = NO;
1718
+ [self setBodyHeight:command];
1719
+ } else {
1720
+ self.bannerView.hidden = NO;
1721
+ }
1746
1722
  }
1747
1723
 
1748
1724
 
@@ -1819,18 +1795,23 @@ NSString *setKeyword = @"";
1819
1795
  if (jsonData) {
1820
1796
  NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
1821
1797
  [self fireEvent:@"" event:@"on.banner.failed.load" withData:jsonString];
1798
+ self.isBannerOpen = NO;
1822
1799
  } else {
1823
1800
  // Fallback in case of JSON serialization failure
1801
+ self.isBannerOpen = NO;
1824
1802
  [self fireEvent:@"" event:@"on.banner.failed.load" withData:error.localizedDescription];
1825
1803
  }
1826
1804
  }
1827
1805
 
1828
1806
  - (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
1829
1807
  [self fireEvent:@"" event:@"on.banner.impression" withData:nil];
1808
+ self.isBannerOpen = YES;
1830
1809
  }
1831
1810
 
1832
1811
  - (void)bannerViewWillPresentScreen:(GADBannerView *)bannerView {
1833
1812
  [self fireEvent:@"" event:@"on.banner.open" withData:nil];
1813
+ self.isBannerOpen = YES;
1814
+
1834
1815
  }
1835
1816
 
1836
1817
  - (void)bannerViewWillDismissScreen:(GADBannerView *)bannerView {