emi-indo-cordova-plugin-admob 2.0.2 → 2.0.3
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/example/www/index.html +4 -0
- package/example/www/js/bannerAd.js +31 -7
- package/package.json +1 -1
- package/plugin.xml +2 -4
- package/src/android/emiAdmobPlugin.kt +23 -17
- package/src/ios/emiAdmobPlugin.h +4 -0
- package/src/ios/emiAdmobPlugin.m +174 -38
package/example/www/index.html
CHANGED
@@ -17,6 +17,10 @@
|
|
17
17
|
|
18
18
|
<p> <button onclick="loadAppOpen();">Auto Show App Open Ad</button></p>
|
19
19
|
|
20
|
+
<p> <button onclick="loadBanner();">load a show Banner Ad</button></p>
|
21
|
+
<p> <button onclick="showBanner();">show Banner Ad</button></p>
|
22
|
+
<p> <button onclick="hideBanner();">hide Banner Ad</button></p>
|
23
|
+
<p> <button onclick="removeBanner();">remove Banner Ad</button></p>
|
20
24
|
|
21
25
|
<p> <button onclick="loadInterstitial();">Load Interstitial Ad</button></p>
|
22
26
|
<p> <button onclick="showInterstitial();">Show Interstitial Ad</button></p>
|
@@ -10,16 +10,16 @@ function loadBanner() {
|
|
10
10
|
|
11
11
|
if (typeof cordova !== 'undefined') {
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
|
15
14
|
cordova.plugins.emiAdmobPlugin.styleBannerAd({
|
16
|
-
isOverlapping: true,
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
isOverlapping: true, // default false IOS | Android
|
16
|
+
isStatusBarShow: true, // default true Only Android
|
17
|
+
paddingWebView: 1.0, // Only IOS > padding banner Container and webView Container
|
18
|
+
overlappingHeight: 0, // default 0 (Automatic) Only Android
|
19
|
+
padding: 0, // default 0 Only Android
|
20
|
+
margins: 0 // default 0 (Automatic) Only Android
|
20
21
|
});
|
21
22
|
|
22
|
-
}
|
23
23
|
|
24
24
|
|
25
25
|
cordova.plugins.emiAdmobPlugin.loadBannerAd({
|
@@ -37,6 +37,30 @@ function loadBanner() {
|
|
37
37
|
|
38
38
|
|
39
39
|
|
40
|
+
function showBanner() {
|
41
|
+
|
42
|
+
if (typeof cordova !== 'undefined') {
|
43
|
+
cordova.plugins.emiAdmobPlugin.showBannerAd();
|
44
|
+
}
|
45
|
+
|
46
|
+
}
|
47
|
+
|
48
|
+
function hideBanner() {
|
49
|
+
|
50
|
+
if (typeof cordova !== 'undefined') {
|
51
|
+
cordova.plugins.emiAdmobPlugin.hideBannerAd();
|
52
|
+
}
|
53
|
+
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
function removeBanner() {
|
58
|
+
|
59
|
+
if (typeof cordova !== 'undefined') {
|
60
|
+
cordova.plugins.emiAdmobPlugin.removeBannerAd();
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
40
64
|
|
41
65
|
|
42
66
|
/* ///////<<<< bannerAd position >>>>>>\\\\\\\
|
package/package.json
CHANGED
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.0.
|
3
|
+
id="emi-indo-cordova-plugin-admob" version="2.0.3">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova/Quasar/Capacitor Plugin Admob Android IOS</description>
|
@@ -51,8 +51,6 @@
|
|
51
51
|
android:value="$APP_ID_ANDROID" />
|
52
52
|
<meta-data android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT"
|
53
53
|
android:value="true" />
|
54
|
-
<meta-data android:name="com.google.android.gms.ads.flag.OPTIMIZE_INITIALIZATION"
|
55
|
-
android:value="false" />
|
56
54
|
<meta-data android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
|
57
55
|
android:value="true" />
|
58
56
|
<meta-data
|
@@ -99,7 +97,7 @@
|
|
99
97
|
|
100
98
|
<config-file parent="/*" target="config.xml">
|
101
99
|
<!--minimum deployment-target: 12.2 -->
|
102
|
-
<preference name="deployment-target" value="
|
100
|
+
<preference name="deployment-target" value="13.0" />
|
103
101
|
<preference name="SwiftVersion" value="5.10" />
|
104
102
|
</config-file>
|
105
103
|
|
@@ -93,6 +93,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
93
93
|
|
94
94
|
private var isOverlapping: Boolean = false
|
95
95
|
private var overlappingHeight: Int = 0
|
96
|
+
private var isStatusBarShow: Boolean = true
|
96
97
|
|
97
98
|
var adType = ""
|
98
99
|
|
@@ -1158,6 +1159,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1158
1159
|
val navBarHeight = maxOf(0, screenHeight - usableHeight)
|
1159
1160
|
|
1160
1161
|
val isOverlapping = options.optBoolean("isOverlapping", false)
|
1162
|
+
val setStatusBarShow = options.optBoolean("isStatusBarShow", true)
|
1161
1163
|
val overlappingHeight = options.optInt("overlappingHeight", navBarHeight)
|
1162
1164
|
val paddingPx = options.optInt("padding", 0)
|
1163
1165
|
val marginsPx = options.optInt("margins", navBarHeight)
|
@@ -1166,6 +1168,7 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1166
1168
|
try {
|
1167
1169
|
// Make sure to only set variables if they have the correct values
|
1168
1170
|
this.isOverlapping = isOverlapping
|
1171
|
+
this.isStatusBarShow = setStatusBarShow
|
1169
1172
|
this.overlappingHeight = if (overlappingHeight > 0) overlappingHeight else navBarHeight
|
1170
1173
|
this.paddingInPx = paddingPx
|
1171
1174
|
this.marginsInPx = if (marginsPx > 0) marginsPx else navBarHeight
|
@@ -1607,27 +1610,30 @@ class emiAdmobPlugin : CordovaPlugin() {
|
|
1607
1610
|
|
1608
1611
|
|
1609
1612
|
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
cWebView?.view?.layoutParams = layoutParams
|
1623
|
-
|
1624
|
-
// Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
|
1625
|
-
} catch (e: Exception) {
|
1626
|
-
Log.e("AdmobPlugin", "Error adjusting WebView for banner: ${e.message}")
|
1613
|
+
private fun bannerOverlapping() {
|
1614
|
+
if (bannerView != null && mActivity != null && cWebView != null) {
|
1615
|
+
mActivity?.runOnUiThread {
|
1616
|
+
try {
|
1617
|
+
val displayMetrics = DisplayMetrics()
|
1618
|
+
mActivity!!.windowManager.defaultDisplay.getMetrics(displayMetrics)
|
1619
|
+
val screenHeightInPx = displayMetrics.heightPixels
|
1620
|
+
|
1621
|
+
val webViewHeight = if (isStatusBarShow) {
|
1622
|
+
screenHeightInPx - (adSize.height + overlappingHeight)
|
1623
|
+
} else {
|
1624
|
+
screenHeightInPx + (adSize.height + overlappingHeight)
|
1627
1625
|
}
|
1626
|
+
val layoutParams = cWebView!!.view.layoutParams
|
1627
|
+
layoutParams.height = webViewHeight
|
1628
|
+
cWebView!!.view.layoutParams = layoutParams
|
1629
|
+
|
1630
|
+
// Log.d("BannerAdjustment", "Adjusted WebView height: $webViewHeight")
|
1631
|
+
} catch (e: Exception) {
|
1632
|
+
Log.e("AdmobPlugin", "Error adjusting WebView for banner: ${e.message}")
|
1628
1633
|
}
|
1629
1634
|
}
|
1630
1635
|
}
|
1636
|
+
}
|
1631
1637
|
|
1632
1638
|
|
1633
1639
|
|
package/src/ios/emiAdmobPlugin.h
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
@property (nonatomic, assign) BOOL isUsingAdManagerRequest;
|
18
18
|
@property (nonatomic, assign) CGFloat viewWidth;
|
19
19
|
@property (nonatomic, strong) UIView *bannerViewLayout;
|
20
|
+
@property (nonatomic, strong) UIView *bannerContainer;
|
21
|
+
@property (nonatomic, strong) UIView *webViewContainer;
|
20
22
|
|
21
23
|
- (void)initialize:(CDVInvokedUrlCommand *)command;
|
22
24
|
- (void)requestIDFA:(CDVInvokedUrlCommand *)command;
|
@@ -26,6 +28,7 @@
|
|
26
28
|
- (void)getIabTfc:(CDVInvokedUrlCommand *)command;
|
27
29
|
- (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command;
|
28
30
|
- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command;
|
31
|
+
- (void)styleBannerAd:(CDVInvokedUrlCommand *)command;
|
29
32
|
- (void)loadBannerAd:(CDVInvokedUrlCommand *)command;
|
30
33
|
- (void)showBannerAd:(CDVInvokedUrlCommand *)command;
|
31
34
|
- (void)hideBannerAd:(CDVInvokedUrlCommand *)command;
|
@@ -38,3 +41,4 @@
|
|
38
41
|
- (void)showRewardedAd:(CDVInvokedUrlCommand *)command;
|
39
42
|
- (void) fireEvent:(NSString *)obj event:(NSString *)eventName withData:(NSString *)jsonStr;
|
40
43
|
@end
|
44
|
+
|
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
#import <Cordova/CDVPlugin.h>
|
5
5
|
#import <Foundation/Foundation.h>
|
6
6
|
#import <UserMessagingPlatform/UserMessagingPlatform.h>
|
7
|
+
#import <Cordova/CDVViewController.h>
|
7
8
|
@implementation emiAdmobPlugin
|
8
9
|
@synthesize appOpenAd;
|
9
10
|
@synthesize bannerView;
|
@@ -18,6 +19,7 @@ int attStatus = 0;
|
|
18
19
|
int Consent_Status = 0;
|
19
20
|
int adFormat = 0;
|
20
21
|
int adWidth = 320; // Default
|
22
|
+
|
21
23
|
BOOL auto_Show = NO;
|
22
24
|
// NSString *Npa = @"1"; // Deprecated
|
23
25
|
NSString *setPosition = @"bottom-center"; // Default
|
@@ -26,6 +28,11 @@ NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
|
|
26
28
|
BOOL isCollapsible = NO;
|
27
29
|
BOOL isAutoResize = NO;
|
28
30
|
|
31
|
+
|
32
|
+
CGFloat paddingWebView = 0; // Default
|
33
|
+
BOOL isSetOverlapping = NO; // Default
|
34
|
+
CGFloat bannerHeightFinal = 50; // Default
|
35
|
+
|
29
36
|
int isAdSkip = 0;
|
30
37
|
BOOL UnderAgeOfConsent = NO;
|
31
38
|
BOOL isPrivacyOptions = NO;
|
@@ -33,6 +40,7 @@ BOOL isDebugGeography = NO;
|
|
33
40
|
BOOL isResponseInfo = NO;
|
34
41
|
BOOL isUsingAdManagerRequest = YES;
|
35
42
|
|
43
|
+
|
36
44
|
- (BOOL)canRequestAds {
|
37
45
|
return UMPConsentInformation.sharedInstance.canRequestAds;
|
38
46
|
}
|
@@ -259,7 +267,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
259
267
|
} else {
|
260
268
|
[UMPConsentForm presentPrivacyOptionsFormFromViewController:self.viewController completionHandler:^(NSError *_Nullable formError) {
|
261
269
|
if (formError) {
|
262
|
-
|
270
|
+
NSLog(@"Error when displaying the form: %@", formError);
|
263
271
|
}
|
264
272
|
}];
|
265
273
|
}
|
@@ -324,8 +332,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
324
332
|
|
325
333
|
- (BOOL)isPrivacyOptionsRequired {
|
326
334
|
UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
|
327
|
-
|
328
|
-
// (long)status);
|
335
|
+
|
329
336
|
return status == UMPPrivacyOptionsRequirementStatusRequired;
|
330
337
|
}
|
331
338
|
|
@@ -347,9 +354,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
347
354
|
Consent_Status = UMPConsentStatusObtained;
|
348
355
|
}
|
349
356
|
|
350
|
-
/* NSLog(@"The Consent "
|
351
|
-
@"Status %i",
|
352
|
-
Consent_Status); */
|
353
357
|
CDVPluginResult *pluginResult =
|
354
358
|
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
355
359
|
messageAsInt:Consent_Status];
|
@@ -448,7 +452,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
448
452
|
requestConfiguration.maxAdContentRating =
|
449
453
|
GADMaxAdContentRatingMatureAudience;
|
450
454
|
} else {
|
451
|
-
|
455
|
+
NSLog(@"Unknown content rating: %@", contentRating);
|
452
456
|
}
|
453
457
|
}
|
454
458
|
|
@@ -538,9 +542,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
538
542
|
[self.bannerViewLayout bringSubviewToFront:self.bannerView];
|
539
543
|
|
540
544
|
} @catch (NSException *exception) {
|
541
|
-
|
542
|
-
// PUBLIC_CALLBACKS.error([NSString stringWithFormat:@"Error adjusting
|
543
|
-
// banner size: %@", exception.reason]);
|
545
|
+
// banner size: %@", exception.reason]);
|
544
546
|
}
|
545
547
|
});
|
546
548
|
}
|
@@ -631,37 +633,12 @@ BOOL isUsingAdManagerRequest = YES;
|
|
631
633
|
|
632
634
|
|
633
635
|
|
634
|
-
- (GADAdSize)__AdSizeFromString:(NSString *)size {
|
635
|
-
|
636
|
-
if (self.viewWidth == 0) {
|
637
|
-
self.viewWidth = [UIScreen mainScreen].bounds.size.width;
|
638
|
-
}
|
639
|
-
|
640
|
-
if ([size isEqualToString:@"responsive_adaptive"]) {
|
641
|
-
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(
|
642
|
-
self.viewWidth);
|
643
|
-
} else if ([size isEqualToString:@"in_line_adaptive"]) {
|
644
|
-
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(
|
645
|
-
self.viewWidth);
|
646
|
-
} else if ([size isEqualToString:@"banner"]) {
|
647
|
-
return GADAdSizeBanner;
|
648
|
-
} else if ([size isEqualToString:@"large_banner"]) {
|
649
|
-
return GADAdSizeLargeBanner;
|
650
|
-
} else if ([size isEqualToString:@"full_banner"]) {
|
651
|
-
return GADAdSizeFullBanner;
|
652
|
-
} else if ([size isEqualToString:@"leaderboard"]) {
|
653
|
-
return GADAdSizeLeaderboard;
|
654
|
-
} else {
|
655
|
-
return GADAdSizeBanner;
|
656
|
-
}
|
657
|
-
}
|
658
|
-
|
659
636
|
- (void)showBannerAd:(CDVInvokedUrlCommand *)command {
|
660
637
|
CDVPluginResult *pluginResult;
|
661
638
|
NSString *callbackId = command.callbackId;
|
662
639
|
if (self.bannerView) {
|
663
640
|
self.bannerView.hidden = NO;
|
664
|
-
|
641
|
+
[self addBannerViewToView:command];
|
665
642
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
666
643
|
} else {
|
667
644
|
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
@@ -730,13 +707,162 @@ BOOL isUsingAdManagerRequest = YES;
|
|
730
707
|
constant:0]
|
731
708
|
]];
|
732
709
|
}
|
710
|
+
[self bannerOverlapping];
|
733
711
|
}
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
- (void)bannerOverlapping {
|
718
|
+
if (!self.bannerView || !self.webView) {
|
719
|
+
NSLog(@"[AdPlugin] Error: Missing bannerView or webView. Adjustment skipped.");
|
720
|
+
return;
|
721
|
+
}
|
722
|
+
|
723
|
+
if (isSetOverlapping){
|
724
|
+
|
725
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
726
|
+
@try {
|
727
|
+
|
728
|
+
CGFloat screenWidth = UIScreen.mainScreen.bounds.size.width;
|
729
|
+
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
|
730
|
+
|
731
|
+
CGFloat navigationBarHeight = 0.0;
|
732
|
+
if (@available(iOS 11.0, *)) {
|
733
|
+
navigationBarHeight = self.viewController.view.safeAreaInsets.bottom;
|
734
|
+
}
|
735
|
+
|
736
|
+
if (!self.bannerContainer) {
|
737
|
+
self.bannerContainer = [[UIView alloc] initWithFrame:CGRectZero];
|
738
|
+
// self.bannerContainer.backgroundColor = [UIColor redColor]; // Debug
|
739
|
+
[self.viewController.view addSubview:self.bannerContainer];
|
740
|
+
}
|
741
|
+
|
742
|
+
if (!self.webViewContainer) {
|
743
|
+
self.webViewContainer = [[UIView alloc] initWithFrame:CGRectZero];
|
744
|
+
// self.webViewContainer.backgroundColor = [UIColor blueColor]; // Debug
|
745
|
+
[self.viewController.view addSubview:self.webViewContainer];
|
746
|
+
}
|
747
|
+
|
748
|
+
CGRect bannerContainerFrame = CGRectZero;
|
749
|
+
if ([setPosition isEqualToString:@"top-center"]) {
|
750
|
+
bannerContainerFrame = CGRectMake(0, 0, screenWidth, bannerHeightFinal);
|
751
|
+
} else if ([setPosition isEqualToString:@"bottom-center"]) {
|
752
|
+
bannerContainerFrame = CGRectMake(0, screenHeight - paddingWebView - bannerHeightFinal - navigationBarHeight, screenWidth, bannerHeightFinal);
|
753
|
+
}
|
754
|
+
self.bannerContainer.frame = bannerContainerFrame;
|
755
|
+
|
756
|
+
self.bannerView.frame = self.bannerContainer.bounds;
|
757
|
+
[self.bannerContainer addSubview:self.bannerView];
|
758
|
+
|
759
|
+
CGRect webViewContainerFrame = CGRectZero;
|
760
|
+
if ([setPosition isEqualToString:@"top-center"]) {
|
761
|
+
webViewContainerFrame = CGRectMake(0, bannerHeightFinal, screenWidth, screenHeight - bannerHeightFinal);
|
762
|
+
} else if ([setPosition isEqualToString:@"bottom-center"]) {
|
763
|
+
|
764
|
+
webViewContainerFrame = CGRectMake(0, 0, screenWidth, screenHeight - bannerHeightFinal - paddingWebView - navigationBarHeight);
|
765
|
+
|
766
|
+
}
|
767
|
+
self.webViewContainer.frame = webViewContainerFrame;
|
768
|
+
|
769
|
+
self.webView.frame = self.webViewContainer.bounds;
|
770
|
+
[self.webViewContainer addSubview:self.webView];
|
771
|
+
|
772
|
+
[self.bannerContainer setNeedsLayout];
|
773
|
+
[self.bannerContainer layoutIfNeeded];
|
774
|
+
[self.webViewContainer setNeedsLayout];
|
775
|
+
[self.webViewContainer layoutIfNeeded];
|
776
|
+
|
777
|
+
|
778
|
+
NSLog(@"[AdPlugin] Banner and WebView are now in separate containers with proper sizing.");
|
779
|
+
} @catch (NSException *exception) {
|
780
|
+
NSLog(@"[AdPlugin] Error adjusting layout for banner and WebView: %@", exception.reason);
|
781
|
+
}
|
782
|
+
|
783
|
+
});
|
784
|
+
}
|
785
|
+
}
|
786
|
+
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
- (void)styleBannerAd:(CDVInvokedUrlCommand *)command {
|
792
|
+
|
793
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
794
|
+
BOOL isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
|
795
|
+
CGFloat paddingContainer = [[options valueForKey:@"paddingWebView"] floatValue];
|
796
|
+
|
797
|
+
isSetOverlapping = isOverlapping;
|
798
|
+
paddingWebView = paddingContainer;
|
799
|
+
|
800
|
+
}
|
801
|
+
|
802
|
+
|
803
|
+
- (GADAdSize)__AdSizeFromString:(NSString *)size {
|
804
|
+
|
805
|
+
if (self.viewWidth == 0) {
|
806
|
+
self.viewWidth = [UIScreen mainScreen].bounds.size.width;
|
807
|
+
}
|
808
|
+
|
809
|
+
if ([size isEqualToString:@"responsive_adaptive"]) {
|
810
|
+
return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(
|
811
|
+
self.viewWidth);
|
812
|
+
} else if ([size isEqualToString:@"in_line_adaptive"]) {
|
813
|
+
return GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(
|
814
|
+
self.viewWidth);
|
815
|
+
} else if ([size isEqualToString:@"banner"]) {
|
816
|
+
return GADAdSizeBanner;
|
817
|
+
} else if ([size isEqualToString:@"large_banner"]) {
|
818
|
+
return GADAdSizeLargeBanner;
|
819
|
+
} else if ([size isEqualToString:@"full_banner"]) {
|
820
|
+
return GADAdSizeFullBanner;
|
821
|
+
} else if ([size isEqualToString:@"leaderboard"]) {
|
822
|
+
return GADAdSizeLeaderboard;
|
823
|
+
} else {
|
824
|
+
return GADAdSizeBanner;
|
825
|
+
}
|
826
|
+
}
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
|
833
|
+
- (void)resetWebViewHeight {
|
834
|
+
if (!self.webView) {
|
835
|
+
NSLog(@"[AdPlugin] Error: WebView is missing. Reset skipped.");
|
836
|
+
return;
|
837
|
+
}
|
838
|
+
|
839
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
840
|
+
@try {
|
841
|
+
|
842
|
+
CGFloat screenHeightInPx = UIScreen.mainScreen.bounds.size.height;
|
843
|
+
|
844
|
+
CGRect webViewFrame = self.webView.frame;
|
845
|
+
webViewFrame.size.height = screenHeightInPx;
|
846
|
+
self.webView.frame = webViewFrame;
|
847
|
+
|
848
|
+
[self.webView setNeedsLayout];
|
849
|
+
[self.webView layoutIfNeeded];
|
850
|
+
|
851
|
+
} @catch (NSException *exception) {
|
852
|
+
NSLog(@"[AdPlugin] Error resetting WebView height: %@", exception.reason);
|
853
|
+
}
|
854
|
+
});
|
855
|
+
}
|
856
|
+
|
857
|
+
|
858
|
+
|
734
859
|
- (void)hideBannerAd:(CDVInvokedUrlCommand *)command {
|
735
860
|
CDVPluginResult *pluginResult;
|
736
861
|
NSString *callbackId = command.callbackId;
|
737
862
|
if (self.bannerView) {
|
738
863
|
dispatch_async(dispatch_get_main_queue(), ^{
|
739
864
|
self.bannerView.hidden = YES;
|
865
|
+
[self resetWebViewHeight];
|
740
866
|
[self fireEvent:@"" event:@"on.banner.hide" withData:nil];
|
741
867
|
});
|
742
868
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
@@ -753,6 +879,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
753
879
|
self.bannerView.hidden = YES;
|
754
880
|
[self.bannerView removeFromSuperview];
|
755
881
|
self.bannerView = nil;
|
882
|
+
[self resetWebViewHeight];
|
756
883
|
[self fireEvent:@"" event:@"on.banner.remove" withData:nil];
|
757
884
|
});
|
758
885
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
@@ -1436,6 +1563,15 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1436
1563
|
return hexString;
|
1437
1564
|
}
|
1438
1565
|
|
1566
|
+
|
1567
|
+
|
1568
|
+
|
1569
|
+
|
1570
|
+
|
1571
|
+
|
1572
|
+
|
1573
|
+
|
1574
|
+
|
1439
1575
|
#pragma mark GADBannerViewDelegate implementation
|
1440
1576
|
|
1441
1577
|
- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
|
@@ -1452,9 +1588,9 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1452
1588
|
|
1453
1589
|
// Get the banner height
|
1454
1590
|
CGFloat bannerHeight = bannerView.bounds.size.height;
|
1591
|
+
bannerHeightFinal = bannerHeight;
|
1455
1592
|
|
1456
1593
|
|
1457
|
-
|
1458
1594
|
// Prepare height data for banner load event
|
1459
1595
|
NSDictionary *bannerLoadData = @{@"height" : @(bannerHeight)};
|
1460
1596
|
NSData *bannerLoadJsonData = [NSJSONSerialization dataWithJSONObject:bannerLoadData options:0 error:&error];
|
@@ -1465,7 +1601,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1465
1601
|
|
1466
1602
|
if (auto_Show && self.bannerView) {
|
1467
1603
|
[self addBannerViewToView:command];
|
1468
|
-
self
|
1604
|
+
[self showBannerAd:command];
|
1469
1605
|
} else {
|
1470
1606
|
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
1471
1607
|
}
|