emi-indo-cordova-plugin-admob 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/example/www/css/index.css +59 -109
- package/example/www/index.html +38 -39
- package/example/www/js/bannerAd.js +8 -4
- package/example/www/js/deviceready.js +5 -5
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/ios/emiAdmobPlugin.m +257 -180
package/README.md
CHANGED
@@ -1,110 +1,60 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
4
|
-
* distributed with this work for additional information
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
7
|
-
* "License"); you may not use this file except in compliance
|
8
|
-
* with the License. You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
13
|
-
* software distributed under the License is distributed on an
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
* KIND, either express or implied. See the License for the
|
16
|
-
* specific language governing permissions and limitations
|
17
|
-
* under the License.
|
18
|
-
*/
|
19
|
-
* {
|
20
|
-
-webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
|
21
|
-
}
|
22
|
-
|
23
1
|
body {
|
24
|
-
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
padding:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
}
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
margin:
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
.
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
display:block;
|
84
|
-
}
|
85
|
-
|
86
|
-
.event.received {
|
87
|
-
background-color:#4B946A;
|
88
|
-
display:none;
|
89
|
-
}
|
90
|
-
|
91
|
-
#deviceready.ready .event.listening { display: none; }
|
92
|
-
#deviceready.ready .event.received { display: block; }
|
93
|
-
|
94
|
-
@keyframes fade {
|
95
|
-
from { opacity: 1.0; }
|
96
|
-
50% { opacity: 0.4; }
|
97
|
-
to { opacity: 1.0; }
|
98
|
-
}
|
99
|
-
|
100
|
-
.blink {
|
101
|
-
animation:fade 3000ms infinite;
|
102
|
-
-webkit-animation:fade 3000ms infinite;
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
@media screen and (prefers-color-scheme: dark) {
|
107
|
-
body {
|
108
|
-
background-image:linear-gradient(to bottom, #585858 0%, #1B1B1B 51%);
|
109
|
-
}
|
110
|
-
}
|
2
|
+
font-family: Arial, sans-serif;
|
3
|
+
margin: 0;
|
4
|
+
height: 100%;
|
5
|
+
padding: 20px;
|
6
|
+
display: flex;
|
7
|
+
flex-direction: column;
|
8
|
+
align-items: center;
|
9
|
+
background-color: #f4f4f4;
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
h1 {
|
14
|
+
color: #333;
|
15
|
+
margin-bottom: 20px;
|
16
|
+
}
|
17
|
+
|
18
|
+
.button-container {
|
19
|
+
display: grid;
|
20
|
+
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
21
|
+
gap: 10px;
|
22
|
+
width: 100%;
|
23
|
+
max-width: 600px;
|
24
|
+
}
|
25
|
+
|
26
|
+
button {
|
27
|
+
padding: 10px 15px;
|
28
|
+
font-size: 14px;
|
29
|
+
border: none;
|
30
|
+
background-color: #007bff;
|
31
|
+
color: white;
|
32
|
+
border-radius: 5px;
|
33
|
+
cursor: pointer;
|
34
|
+
text-align: center;
|
35
|
+
transition: background-color 0.3s ease;
|
36
|
+
}
|
37
|
+
|
38
|
+
button:hover {
|
39
|
+
background-color: #0056b3;
|
40
|
+
}
|
41
|
+
|
42
|
+
textarea {
|
43
|
+
width: 100%;
|
44
|
+
max-width: 600px;
|
45
|
+
margin-top: 20px;
|
46
|
+
padding: 10px;
|
47
|
+
font-size: 14px;
|
48
|
+
border: 1px solid #ccc;
|
49
|
+
border-radius: 5px;
|
50
|
+
resize: none;
|
51
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
52
|
+
height: 150px;
|
53
|
+
}
|
54
|
+
|
55
|
+
label {
|
56
|
+
font-size: 16px;
|
57
|
+
font-weight: bold;
|
58
|
+
margin-top: 20px;
|
59
|
+
color: #333;
|
60
|
+
}
|
package/example/www/index.html
CHANGED
@@ -1,44 +1,43 @@
|
|
1
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
2
3
|
<head>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
6
|
+
<meta name="theme-color" content="#000000">
|
7
|
+
<title>Cordova | Capacitor | Quasar</title>
|
8
|
+
<style> </style>
|
9
|
+
<link rel="stylesheet" href="css/index.css">
|
10
|
+
<script type="text/javascript" src="cordova.js"></script>
|
11
|
+
<script src="js/deviceready.js" defer></script>
|
12
|
+
<script src="js/appOpenAd.js" defer></script>
|
13
|
+
<script src="js/bannerAd.js" defer></script>
|
14
|
+
<script src="js/interstitialAd.js" defer></script>
|
15
|
+
<script src="js/rewardedAd.js" defer></script>
|
16
|
+
<script src="js/rewardedInterstitialAd.js" defer></script>
|
17
|
+
<script src="js/adSense.js" defer></script>
|
18
|
+
<script src="js/privacyOptionsFormShow.js" defer></script>
|
12
19
|
</head>
|
13
20
|
<body>
|
14
|
-
|
15
|
-
|
16
|
-
<
|
17
|
-
<
|
18
|
-
|
19
|
-
<
|
20
|
-
|
21
|
-
<
|
22
|
-
<
|
23
|
-
<
|
24
|
-
<
|
25
|
-
|
26
|
-
<
|
27
|
-
<
|
28
|
-
|
29
|
-
<
|
30
|
-
<
|
31
|
-
|
32
|
-
|
33
|
-
<
|
34
|
-
|
35
|
-
<p> <button onclick="registerWebView();">AdSense Register</button></p>
|
36
|
-
<p> <button onclick="loadUrl();">AdSense load Url</button></p>
|
37
|
-
|
38
|
-
<p> <button onclick="showPrivacyOptionsForm();">Show Privacy Options Form</button></p>
|
39
|
-
<p> <button onclick="forceDisplayPrivacyForm();">Force Display Privacy Form</button></p>
|
40
|
-
|
41
|
-
<p> <button onclick="cleanText();">Clean response Text</button></p>
|
42
|
-
|
21
|
+
<h1>Ad Management Panel</h1>
|
22
|
+
<div class="button-container">
|
23
|
+
<button onclick="loadAppOpen();">Auto Show App Open Ad</button>
|
24
|
+
<button onclick="loadBanner();">Load and Show Banner Ad</button>
|
25
|
+
<button onclick="showBanner();">Show Banner Ad</button>
|
26
|
+
<button onclick="hideBanner();">Hide Banner Ad</button>
|
27
|
+
<button onclick="removeBanner();">Remove Banner Ad</button>
|
28
|
+
<button onclick="loadInterstitial();">Load Interstitial Ad</button>
|
29
|
+
<button onclick="showInterstitial();">Show Interstitial Ad</button>
|
30
|
+
<button onclick="loadRewarded();">Load Rewarded Ad</button>
|
31
|
+
<button onclick="showRewarded();">Show Rewarded Ad</button>
|
32
|
+
<button onclick="loadRewardedInt();">Load Rewarded Int Ad</button>
|
33
|
+
<button onclick="showRewardedInt();">Show Rewarded Int Ad</button>
|
34
|
+
<button onclick="registerWebView();">AdSense Register</button>
|
35
|
+
<button onclick="loadUrl();">AdSense Load Url</button>
|
36
|
+
<button onclick="showPrivacyOptionsForm();">Show Privacy Options Form</button>
|
37
|
+
<button onclick="forceDisplayPrivacyForm();">Force Display Privacy Form</button>
|
38
|
+
<button onclick="cleanText();">Clean Response Text</button>
|
39
|
+
</div>
|
40
|
+
<label for="log">Debug Event All Response:</label>
|
41
|
+
<textarea id="log" name="log" placeholder="Logs will appear here..."></textarea>
|
43
42
|
</body>
|
44
43
|
</html>
|
@@ -41,7 +41,7 @@ function loadBanner() {
|
|
41
41
|
adUnitId: Banner_ID, //Banner_ID,
|
42
42
|
position: "bottom-center", // "Recommended: bottom-center"
|
43
43
|
size: "banner", // autoResize: true (only responsive_adaptive)
|
44
|
-
collapsible: "
|
44
|
+
collapsible: "", // position: top | bottom (disable, empty string)
|
45
45
|
autoResize: true, // default false
|
46
46
|
autoShow: true, // default false
|
47
47
|
|
@@ -158,7 +158,7 @@ on.banner.hide
|
|
158
158
|
// This is only triggered when cordova.plugins.emiAdmobPlugin.styleBannerAd
|
159
159
|
document.addEventListener('on.style.banner.ad', (data) => {
|
160
160
|
console.log("on.style.banner.ad: " + JSON.stringify(data));
|
161
|
-
/*
|
161
|
+
/* (ANDROID)
|
162
162
|
const navBarHeight = data.navBarHeight;
|
163
163
|
const screenHeight = data.screenHeight;
|
164
164
|
const usableHeight = data.usableHeight;
|
@@ -168,8 +168,12 @@ document.addEventListener('on.style.banner.ad', (data) => {
|
|
168
168
|
const marginsInPx = data.marginsInPx;
|
169
169
|
*/
|
170
170
|
|
171
|
-
|
172
|
-
|
171
|
+
/* (IOS)
|
172
|
+
const screenHeight = data.screenHeight;
|
173
|
+
const screenWidth = data.screenWidth;
|
174
|
+
const safeAreaTop = data.safeAreaTop;
|
175
|
+
const safeAreaBottom = data.safeAreaBottom;
|
176
|
+
*/
|
173
177
|
|
174
178
|
});
|
175
179
|
|
@@ -77,7 +77,7 @@ document.addEventListener("deviceready", function () {
|
|
77
77
|
|
78
78
|
|
79
79
|
if (isPlatformIOS){
|
80
|
-
|
80
|
+
// with callback: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/issues/57
|
81
81
|
cordova.plugins.emiAdmobPlugin.requestIDFA(); // requestTrackingAuthorization
|
82
82
|
|
83
83
|
}
|
@@ -100,8 +100,8 @@ document.addEventListener("deviceready", function () {
|
|
100
100
|
cordova.plugins.emiAdmobPlugin.initialize({
|
101
101
|
|
102
102
|
isUsingAdManagerRequest: true, // true = AdManager | false = AdMob (Default true)
|
103
|
-
isResponseInfo:
|
104
|
-
isConsentDebug:
|
103
|
+
isResponseInfo: false, // debug true | Production false
|
104
|
+
isConsentDebug: false, // debug true | Production false
|
105
105
|
|
106
106
|
});
|
107
107
|
|
@@ -112,8 +112,8 @@ document.addEventListener("deviceready", function () {
|
|
112
112
|
// JSON.stringify(data)
|
113
113
|
const sdkVersion = data.version;
|
114
114
|
// const adAdapter = data.adapters;
|
115
|
-
const conStatus = data.consentStatus;
|
116
|
-
const attStatus = data.attStatus;
|
115
|
+
const conStatus = data.consentStatus; // UMP
|
116
|
+
const attStatus = data.attStatus; // ATT
|
117
117
|
// const gdprApplie = data.gdprApplies;
|
118
118
|
// const purposeConsent = data.purposeConsents;
|
119
119
|
// const vendorConsents = data.vendorConsents;
|
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.6">
|
4
4
|
|
5
5
|
<name>emiAdmobPlugin</name>
|
6
6
|
<description>Cordova/Quasar/Capacitor Plugin Admob Android IOS</description>
|
package/src/ios/emiAdmobPlugin.m
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
#import <Foundation/Foundation.h>
|
6
6
|
#import <UserMessagingPlatform/UserMessagingPlatform.h>
|
7
7
|
#import <Cordova/CDVViewController.h>
|
8
|
+
|
8
9
|
@implementation emiAdmobPlugin
|
9
10
|
@synthesize appOpenAd;
|
10
11
|
@synthesize bannerView;
|
@@ -81,6 +82,10 @@ NSString *setKeyword = @"";
|
|
81
82
|
|
82
83
|
|
83
84
|
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
84
89
|
- (void)isResponseInfo:(BOOL)value {
|
85
90
|
isResponseInfo = value;
|
86
91
|
}
|
@@ -173,35 +178,41 @@ NSString *setKeyword = @"";
|
|
173
178
|
|
174
179
|
|
175
180
|
- (void)requestIDFA:(CDVInvokedUrlCommand *)command {
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
181
|
+
__block CDVPluginResult *pluginResult;
|
182
|
+
NSString *callbackId = command.callbackId;
|
183
|
+
|
184
|
+
if (@available(iOS 14, *)) {
|
185
|
+
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
|
+
|
189
|
+
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
|
190
|
+
if (status == ATTrackingManagerAuthorizationStatusDenied) {
|
191
|
+
attStatus = ATTrackingManagerAuthorizationStatusDenied;
|
192
|
+
} else if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
|
193
|
+
attStatus = ATTrackingManagerAuthorizationStatusAuthorized;
|
194
|
+
} else if (status == ATTrackingManagerAuthorizationStatusRestricted) {
|
195
|
+
attStatus = ATTrackingManagerAuthorizationStatusRestricted;
|
196
|
+
} else if (status == ATTrackingManagerAuthorizationStatusNotDetermined) {
|
197
|
+
attStatus = ATTrackingManagerAuthorizationStatusNotDetermined;
|
198
|
+
}
|
199
|
+
[self fireEvent:@"" event:@"on.getIDFA.status" withData:nil];
|
200
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:attStatus];
|
201
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
202
|
+
}];
|
203
|
+
});
|
204
|
+
});
|
205
|
+
} else {
|
206
|
+
[self fireEvent:@"" event:@"on.getIDFA.error" withData:nil];
|
207
|
+
|
208
|
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"iOS 14+ not found"];
|
209
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
210
|
+
}
|
203
211
|
}
|
204
212
|
|
213
|
+
|
214
|
+
|
215
|
+
|
205
216
|
- (void)startGoogleMobileAdsSDK {
|
206
217
|
static dispatch_once_t onceToken;
|
207
218
|
dispatch_once(&onceToken, ^{
|
@@ -559,7 +570,7 @@ NSString *setKeyword = @"";
|
|
559
570
|
[self.bannerViewLayout.trailingAnchor
|
560
571
|
constraintEqualToAnchor:rootView.trailingAnchor]
|
561
572
|
.active = YES;
|
562
|
-
|
573
|
+
[self.bannerViewLayout.heightAnchor constraintEqualToConstant:bannerHeightFinal]
|
563
574
|
.active = YES;
|
564
575
|
}
|
565
576
|
|
@@ -573,9 +584,21 @@ NSString *setKeyword = @"";
|
|
573
584
|
|
574
585
|
[self.bannerViewLayout addSubview:self.bannerView];
|
575
586
|
[self.bannerViewLayout bringSubviewToFront:self.bannerView];
|
587
|
+
|
588
|
+
if (isSetOverlapping) {
|
589
|
+
|
590
|
+
if (auto_Show && self.bannerView) {
|
591
|
+
if (isSetOverlapping){
|
592
|
+
self.bannerView.hidden = NO;
|
593
|
+
[self setBodyHeight:self.command];
|
594
|
+
}
|
595
|
+
}
|
596
|
+
|
597
|
+
|
598
|
+
}
|
576
599
|
|
577
600
|
} @catch (NSException *exception) {
|
578
|
-
|
601
|
+
NSLog(@"Exception: %@", exception.reason);
|
579
602
|
}
|
580
603
|
});
|
581
604
|
}
|
@@ -621,7 +644,7 @@ NSString *setKeyword = @"";
|
|
621
644
|
|
622
645
|
if (adFormat == 5) {
|
623
646
|
dispatch_async(dispatch_get_main_queue(), ^{
|
624
|
-
UIView *parentView =
|
647
|
+
UIView *parentView = self.viewController.view;
|
625
648
|
CGRect frame = self.bannerView.frame;
|
626
649
|
|
627
650
|
if (@available(iOS 11.0, *)) {
|
@@ -651,8 +674,10 @@ NSString *setKeyword = @"";
|
|
651
674
|
self.bannerView.delegate = self;
|
652
675
|
[self.bannerView loadRequest:self.globalRequest];
|
653
676
|
self.bannerView.hidden = YES;
|
654
|
-
[parentView
|
655
|
-
|
677
|
+
if (![parentView.subviews containsObject:self.bannerView]) {
|
678
|
+
[parentView addSubview:self.bannerView];
|
679
|
+
[parentView bringSubviewToFront:self.bannerView];
|
680
|
+
}
|
656
681
|
});
|
657
682
|
|
658
683
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
@@ -669,7 +694,10 @@ NSString *setKeyword = @"";
|
|
669
694
|
@try {
|
670
695
|
if (self.bannerView) {
|
671
696
|
self.bannerView.hidden = NO;
|
672
|
-
|
697
|
+
if (isSetOverlapping){
|
698
|
+
[self setBodyHeight:command];
|
699
|
+
}
|
700
|
+
|
673
701
|
} else {
|
674
702
|
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
675
703
|
}
|
@@ -680,146 +708,126 @@ NSString *setKeyword = @"";
|
|
680
708
|
}
|
681
709
|
|
682
710
|
|
683
|
-
- (
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
[self.viewController.view addConstraints:@[
|
688
|
-
[NSLayoutConstraint
|
689
|
-
constraintWithItem:bannerView
|
690
|
-
attribute:NSLayoutAttributeBottom
|
691
|
-
relatedBy:NSLayoutRelationEqual
|
692
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
693
|
-
attribute:NSLayoutAttributeBottom
|
694
|
-
multiplier:1
|
695
|
-
constant:0],
|
696
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
697
|
-
attribute:NSLayoutAttributeCenterX
|
698
|
-
relatedBy:NSLayoutRelationEqual
|
699
|
-
toItem:self.viewController.view
|
700
|
-
attribute:NSLayoutAttributeCenterX
|
701
|
-
multiplier:1
|
702
|
-
constant:0]
|
703
|
-
]];
|
704
|
-
} else if ([setPosition isEqualToString:@"top-center"]) {
|
705
|
-
|
706
|
-
[self.viewController.view addConstraints:@[
|
707
|
-
[NSLayoutConstraint
|
708
|
-
constraintWithItem:bannerView
|
709
|
-
attribute:NSLayoutAttributeTop
|
710
|
-
relatedBy:NSLayoutRelationEqual
|
711
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
712
|
-
attribute:NSLayoutAttributeTop
|
713
|
-
multiplier:1
|
714
|
-
constant:0],
|
715
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
716
|
-
attribute:NSLayoutAttributeCenterX
|
717
|
-
relatedBy:NSLayoutRelationEqual
|
718
|
-
toItem:self.viewController.view
|
719
|
-
attribute:NSLayoutAttributeCenterX
|
720
|
-
multiplier:1
|
721
|
-
constant:0]
|
722
|
-
]];
|
711
|
+
- (UIView*)findWebViewInView:(UIView*)view {
|
712
|
+
if ([view isKindOfClass:NSClassFromString(@"WKWebView")] || [view isKindOfClass:NSClassFromString(@"UIWebView")]) {
|
713
|
+
return view;
|
714
|
+
}
|
723
715
|
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
relatedBy:NSLayoutRelationEqual
|
730
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
731
|
-
attribute:NSLayoutAttributeTop
|
732
|
-
multiplier:1
|
733
|
-
constant:0],
|
734
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
735
|
-
attribute:NSLayoutAttributeCenterX
|
736
|
-
relatedBy:NSLayoutRelationEqual
|
737
|
-
toItem:self.viewController.view
|
738
|
-
attribute:NSLayoutAttributeCenterX
|
739
|
-
multiplier:1
|
740
|
-
constant:0]
|
741
|
-
]];
|
742
|
-
}
|
743
|
-
if (isSetOverlapping){
|
744
|
-
[self bannerOverlapping];
|
716
|
+
for (UIView* subview in view.subviews) {
|
717
|
+
UIView* found = [self findWebViewInView:subview];
|
718
|
+
if (found) {
|
719
|
+
return found;
|
720
|
+
}
|
745
721
|
}
|
722
|
+
|
723
|
+
return nil;
|
746
724
|
}
|
747
725
|
|
748
726
|
|
727
|
+
- (void)setBodyHeight:(CDVInvokedUrlCommand*)command {
|
728
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
729
|
+
@try {
|
749
730
|
|
731
|
+
UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
|
732
|
+
UIViewController* rootViewController = keyWindow.rootViewController;
|
750
733
|
|
734
|
+
if (!rootViewController) {
|
735
|
+
CDVPluginResult* errorResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Root ViewController not found"];
|
736
|
+
[self.commandDelegate sendPluginResult:errorResult callbackId:command.callbackId];
|
737
|
+
return;
|
738
|
+
}
|
739
|
+
|
740
|
+
|
741
|
+
[rootViewController.view setNeedsLayout];
|
742
|
+
[rootViewController.view layoutIfNeeded];
|
751
743
|
|
752
|
-
|
753
|
-
if (!self.bannerView || !self.webView) {
|
754
|
-
NSLog(@"[AdPlugin] Error: Missing bannerView or webView. Adjustment skipped.");
|
755
|
-
return;
|
756
|
-
}
|
757
|
-
|
758
|
-
if (isSetOverlapping){
|
759
|
-
|
760
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
761
|
-
@try {
|
744
|
+
UIEdgeInsets safeAreaInsets = rootViewController.view.safeAreaInsets;
|
762
745
|
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
CGFloat navigationBarHeight = 0.0;
|
767
|
-
if (@available(iOS 11.0, *)) {
|
768
|
-
navigationBarHeight = self.viewController.view.safeAreaInsets.bottom;
|
769
|
-
}
|
770
|
-
|
771
|
-
if (!self.bannerContainer) {
|
772
|
-
self.bannerContainer = [[UIView alloc] initWithFrame:CGRectZero];
|
773
|
-
// self.bannerContainer.backgroundColor = [UIColor redColor]; // Debug
|
774
|
-
[self.viewController.view addSubview:self.bannerContainer];
|
775
|
-
}
|
776
|
-
|
777
|
-
if (!self.webViewContainer) {
|
778
|
-
self.webViewContainer = [[UIView alloc] initWithFrame:CGRectZero];
|
779
|
-
// self.webViewContainer.backgroundColor = [UIColor blueColor]; // Debug
|
780
|
-
[self.viewController.view addSubview:self.webViewContainer];
|
781
|
-
}
|
782
|
-
|
783
|
-
CGRect bannerContainerFrame = CGRectZero;
|
784
|
-
if ([setPosition isEqualToString:@"top-center"]) {
|
785
|
-
bannerContainerFrame = CGRectMake(0, 0, screenWidth, bannerHeightFinal);
|
786
|
-
} else if ([setPosition isEqualToString:@"bottom-center"]) {
|
787
|
-
bannerContainerFrame = CGRectMake(0, screenHeight - paddingWebView - bannerHeightFinal - navigationBarHeight, screenWidth, bannerHeightFinal);
|
788
|
-
}
|
789
|
-
self.bannerContainer.frame = bannerContainerFrame;
|
790
|
-
|
791
|
-
self.bannerView.frame = self.bannerContainer.bounds;
|
792
|
-
[self.bannerContainer addSubview:self.bannerView];
|
793
|
-
|
794
|
-
CGRect webViewContainerFrame = CGRectZero;
|
795
|
-
if ([setPosition isEqualToString:@"top-center"]) {
|
796
|
-
webViewContainerFrame = CGRectMake(0, bannerHeightFinal, screenWidth, screenHeight - bannerHeightFinal);
|
797
|
-
} else if ([setPosition isEqualToString:@"bottom-center"]) {
|
798
|
-
|
799
|
-
webViewContainerFrame = CGRectMake(0, 0, screenWidth, screenHeight - bannerHeightFinal - paddingWebView - navigationBarHeight);
|
800
|
-
|
801
|
-
}
|
802
|
-
self.webViewContainer.frame = webViewContainerFrame;
|
803
|
-
|
804
|
-
self.webView.frame = self.webViewContainer.bounds;
|
805
|
-
[self.webViewContainer addSubview:self.webView];
|
806
|
-
|
807
|
-
[self.bannerContainer setNeedsLayout];
|
808
|
-
[self.bannerContainer layoutIfNeeded];
|
809
|
-
[self.webViewContainer setNeedsLayout];
|
810
|
-
[self.webViewContainer layoutIfNeeded];
|
811
|
-
|
812
|
-
|
813
|
-
NSLog(@"[AdPlugin] Banner and WebView are now in separate containers with proper sizing.");
|
814
|
-
} @catch (NSException *exception) {
|
815
|
-
NSLog(@"[AdPlugin] Error adjusting layout for banner and WebView: %@", exception.reason);
|
746
|
+
if (safeAreaInsets.bottom == 0) {
|
747
|
+
safeAreaInsets = keyWindow.safeAreaInsets;
|
816
748
|
}
|
817
|
-
|
818
|
-
|
819
|
-
|
749
|
+
|
750
|
+
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
|
751
|
+
CGFloat screenWidth = UIScreen.mainScreen.bounds.size.width;
|
752
|
+
CGFloat bannerHeight = bannerHeightFinal;
|
753
|
+
CGFloat newHeight = screenHeight - bannerHeight;
|
754
|
+
|
755
|
+
|
756
|
+
if (newHeight <= 0) {
|
757
|
+
|
758
|
+
CDVPluginResult* errorResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid new height"];
|
759
|
+
[self.commandDelegate sendPluginResult:errorResult callbackId:command.callbackId];
|
760
|
+
return;
|
761
|
+
}
|
762
|
+
|
763
|
+
UIView *webView = [self findWebViewInView:rootViewController.view];
|
764
|
+
if (webView) {
|
765
|
+
CGRect webViewFrame = webView.frame;
|
766
|
+
webViewFrame.size.height = newHeight;
|
767
|
+
webView.frame = webViewFrame;
|
768
|
+
} else {
|
769
|
+
NSLog(@"[CordovaBodyHeight] WebView not found");
|
770
|
+
}
|
771
|
+
|
772
|
+
if ([setPosition isEqualToString:@"top-center"]) {
|
773
|
+
CGRect currentBannerFrame = self.bannerView.frame;
|
774
|
+
CGFloat expectedYPosition = safeAreaInsets.top;
|
775
|
+
|
776
|
+
if (fabs(currentBannerFrame.origin.y - expectedYPosition) > 0.1) {
|
777
|
+
CGRect bannerFrame = CGRectMake(0, expectedYPosition, screenWidth, bannerHeight);
|
778
|
+
self.bannerView.frame = bannerFrame;
|
779
|
+
CGRect contentFrame = rootViewController.view.frame;
|
780
|
+
contentFrame.origin.y = bannerHeight + safeAreaInsets.top;
|
781
|
+
contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.top);
|
782
|
+
rootViewController.view.frame = contentFrame;
|
783
|
+
}
|
784
|
+
} else if ([setPosition isEqualToString:@"bottom-center"]) {
|
785
|
+
|
786
|
+
CGRect bannerFrame = CGRectMake(
|
787
|
+
0,
|
788
|
+
screenHeight - bannerHeight - safeAreaInsets.bottom + paddingWebView,
|
789
|
+
screenWidth,
|
790
|
+
bannerHeight
|
791
|
+
);
|
792
|
+
self.bannerView.frame = bannerFrame;
|
793
|
+
|
794
|
+
CGRect contentFrame = rootViewController.view.frame;
|
795
|
+
contentFrame.origin.y = 0;
|
796
|
+
contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.bottom);
|
797
|
+
rootViewController.view.frame = contentFrame;
|
798
|
+
|
799
|
+
} else {
|
800
|
+
CGRect bannerFrame = CGRectMake(
|
801
|
+
0,
|
802
|
+
screenHeight - bannerHeight - safeAreaInsets.bottom + paddingWebView,
|
803
|
+
screenWidth,
|
804
|
+
bannerHeight
|
805
|
+
);
|
806
|
+
self.bannerView.frame = bannerFrame;
|
807
|
+
|
808
|
+
CGRect contentFrame = rootViewController.view.frame;
|
809
|
+
contentFrame.origin.y = 0;
|
810
|
+
contentFrame.size.height = screenHeight - (bannerHeight + safeAreaInsets.bottom);
|
811
|
+
rootViewController.view.frame = contentFrame;
|
812
|
+
|
813
|
+
}
|
814
|
+
|
815
|
+
[self.bannerView setNeedsLayout];
|
816
|
+
[self.bannerView layoutIfNeeded];
|
817
|
+
[rootViewController.view setNeedsLayout];
|
818
|
+
[rootViewController.view layoutIfNeeded];
|
819
|
+
|
820
|
+
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:newHeight];
|
821
|
+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
822
|
+
}
|
823
|
+
@catch (NSException* exception) {
|
824
|
+
NSLog(@"[CordovaBodyHeight] Exception: %@", exception.reason);
|
825
|
+
}
|
826
|
+
});
|
820
827
|
}
|
821
828
|
|
822
829
|
|
830
|
+
|
823
831
|
- (void)metaData:(CDVInvokedUrlCommand *)command {
|
824
832
|
NSDictionary *options = [command.arguments objectAtIndex:0];
|
825
833
|
BOOL useCustomConsentManager = [[options valueForKey:@"useCustomConsentManager"] boolValue];
|
@@ -829,11 +837,11 @@ NSString *setKeyword = @"";
|
|
829
837
|
isCustomConsentManager = useCustomConsentManager;
|
830
838
|
isEnabledKeyword = useCustomKeyword;
|
831
839
|
setKeyword = keywordValue;
|
840
|
+
|
832
841
|
}
|
833
842
|
|
834
843
|
|
835
844
|
- (void)styleBannerAd:(CDVInvokedUrlCommand *)command {
|
836
|
-
|
837
845
|
NSDictionary *options = [command.arguments objectAtIndex:0];
|
838
846
|
BOOL isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
|
839
847
|
CGFloat paddingContainer = [[options valueForKey:@"paddingWebView"] floatValue];
|
@@ -841,9 +849,57 @@ NSString *setKeyword = @"";
|
|
841
849
|
isSetOverlapping = isOverlapping;
|
842
850
|
paddingWebView = paddingContainer;
|
843
851
|
|
852
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
853
|
+
@try {
|
854
|
+
|
855
|
+
UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
|
856
|
+
UIViewController *rootViewController = keyWindow.rootViewController;
|
857
|
+
|
858
|
+
if (!rootViewController) {
|
859
|
+
CDVPluginResult *errorResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Root ViewController not found"];
|
860
|
+
[self.commandDelegate sendPluginResult:errorResult callbackId:command.callbackId];
|
861
|
+
return;
|
862
|
+
}
|
863
|
+
|
864
|
+
UIEdgeInsets safeAreaInsets = rootViewController.view.safeAreaInsets;
|
865
|
+
|
866
|
+
if (safeAreaInsets.bottom == 0) {
|
867
|
+
safeAreaInsets = keyWindow.safeAreaInsets;
|
868
|
+
}
|
869
|
+
|
870
|
+
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
|
871
|
+
CGFloat screenWidth = UIScreen.mainScreen.bounds.size.width;
|
872
|
+
|
873
|
+
NSDictionary *data = @{
|
874
|
+
@"screenHeight": @(screenHeight),
|
875
|
+
@"screenWidth": @(screenWidth),
|
876
|
+
@"safeAreaTop": @(safeAreaInsets.top),
|
877
|
+
@"safeAreaBottom": @(safeAreaInsets.bottom)
|
878
|
+
};
|
879
|
+
|
880
|
+
NSError *jsonError;
|
881
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:&jsonError];
|
882
|
+
|
883
|
+
if (jsonError) {
|
884
|
+
CDVPluginResult *errorResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Error converting dictionary to JSON"];
|
885
|
+
[self.commandDelegate sendPluginResult:errorResult callbackId:command.callbackId];
|
886
|
+
return;
|
887
|
+
}
|
888
|
+
|
889
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
890
|
+
|
891
|
+
[self fireEvent:@"" event:@"on.style.banner.ad" withData:jsonString];
|
892
|
+
|
893
|
+
|
894
|
+
} @catch (NSException *exception) {
|
895
|
+
NSLog(@"[CordovaBodyHeight] Exception: %@", exception.reason);
|
896
|
+
|
897
|
+
}
|
898
|
+
});
|
844
899
|
}
|
845
900
|
|
846
901
|
|
902
|
+
|
847
903
|
- (GADAdSize)__AdSizeFromString:(NSString *)size {
|
848
904
|
|
849
905
|
if (self.viewWidth == 0) {
|
@@ -872,34 +928,48 @@ NSString *setKeyword = @"";
|
|
872
928
|
|
873
929
|
|
874
930
|
|
931
|
+
- (void)resetWebViewHeight {
|
932
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
933
|
+
UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
|
934
|
+
UIViewController *rootViewController = keyWindow.rootViewController;
|
875
935
|
|
936
|
+
if (!rootViewController) {
|
937
|
+
NSLog(@"[CordovaBodyHeight] Root ViewController not found on reset");
|
938
|
+
return;
|
939
|
+
}
|
876
940
|
|
877
|
-
|
878
|
-
if (!self.webView) {
|
879
|
-
NSLog(@"[AdPlugin] Error: WebView is missing. Reset skipped.");
|
880
|
-
return;
|
881
|
-
}
|
941
|
+
UIEdgeInsets safeAreaInsets = rootViewController.view.safeAreaInsets;
|
882
942
|
|
883
|
-
|
884
|
-
|
943
|
+
if (safeAreaInsets.bottom == 0) {
|
944
|
+
safeAreaInsets = keyWindow.safeAreaInsets;
|
945
|
+
}
|
885
946
|
|
886
|
-
|
947
|
+
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
|
887
948
|
|
888
|
-
|
889
|
-
|
890
|
-
|
949
|
+
CGRect contentFrame = rootViewController.view.frame;
|
950
|
+
contentFrame.origin.y = 0;
|
951
|
+
contentFrame.size.height = screenHeight - safeAreaInsets.bottom;
|
952
|
+
rootViewController.view.frame = contentFrame;
|
891
953
|
|
892
|
-
|
893
|
-
|
954
|
+
UIView *webView = [self findWebViewInView:rootViewController.view];
|
955
|
+
if (webView) {
|
956
|
+
CGRect webViewFrame = webView.frame;
|
957
|
+
webViewFrame.origin.y = 0;
|
958
|
+
webViewFrame.size.height = screenHeight - safeAreaInsets.bottom;
|
959
|
+
webView.frame = webViewFrame;
|
894
960
|
|
895
|
-
}
|
896
|
-
NSLog(@"[
|
961
|
+
} else {
|
962
|
+
NSLog(@"[CordovaBodyHeight] WebView not found on reset");
|
897
963
|
}
|
964
|
+
|
965
|
+
[rootViewController.view setNeedsLayout];
|
966
|
+
[rootViewController.view layoutIfNeeded];
|
898
967
|
});
|
899
968
|
}
|
900
969
|
|
901
970
|
|
902
971
|
|
972
|
+
|
903
973
|
- (void)hideBannerAd:(CDVInvokedUrlCommand *)command {
|
904
974
|
CDVPluginResult *pluginResult;
|
905
975
|
NSString *callbackId = command.callbackId;
|
@@ -915,6 +985,9 @@ NSString *setKeyword = @"";
|
|
915
985
|
}
|
916
986
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
917
987
|
}
|
988
|
+
|
989
|
+
|
990
|
+
|
918
991
|
- (void)removeBannerAd:(CDVInvokedUrlCommand *)command {
|
919
992
|
CDVPluginResult *pluginResult;
|
920
993
|
NSString *callbackId = command.callbackId;
|
@@ -923,8 +996,8 @@ NSString *setKeyword = @"";
|
|
923
996
|
self.bannerView.hidden = YES;
|
924
997
|
[self.bannerView removeFromSuperview];
|
925
998
|
self.bannerView = nil;
|
926
|
-
|
927
|
-
|
999
|
+
[self resetWebViewHeight];
|
1000
|
+
[self fireEvent:@"" event:@"on.banner.remove" withData:nil];
|
928
1001
|
});
|
929
1002
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
930
1003
|
} else {
|
@@ -1644,7 +1717,10 @@ NSString *setKeyword = @"";
|
|
1644
1717
|
[self fireEvent:@"" event:@"on.banner.load" withData:bannerLoadJsonString];
|
1645
1718
|
|
1646
1719
|
if (auto_Show && self.bannerView) {
|
1647
|
-
|
1720
|
+
if (isSetOverlapping){
|
1721
|
+
self.bannerView.hidden = NO;
|
1722
|
+
[self setBodyHeight:command];
|
1723
|
+
}
|
1648
1724
|
} else {
|
1649
1725
|
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
1650
1726
|
}
|
@@ -1729,7 +1805,6 @@ NSString *setKeyword = @"";
|
|
1729
1805
|
}
|
1730
1806
|
}
|
1731
1807
|
|
1732
|
-
|
1733
1808
|
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
1734
1809
|
[self fireEvent:@"" event:@"on.banner.impression" withData:nil];
|
1735
1810
|
}
|
@@ -1744,6 +1819,7 @@ NSString *setKeyword = @"";
|
|
1744
1819
|
|
1745
1820
|
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
1746
1821
|
[self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
|
1822
|
+
|
1747
1823
|
}
|
1748
1824
|
|
1749
1825
|
#pragma mark GADFullScreeContentDelegate implementation
|
@@ -1822,3 +1898,4 @@ NSString *setKeyword = @"";
|
|
1822
1898
|
object:nil];
|
1823
1899
|
}
|
1824
1900
|
@end
|
1901
|
+
|