emi-indo-cordova-plugin-admob 2.0.4 → 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 -35
- package/example/www/js/bannerAd.js +26 -7
- package/example/www/js/deviceready.js +11 -11
- package/example/www/js/privacyOptionsFormShow.js +33 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/ios/emiAdmobPlugin.h +1 -0
- package/src/ios/emiAdmobPlugin.m +312 -192
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,40 +1,43 @@
|
|
1
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
2
3
|
<head>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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>
|
11
19
|
</head>
|
12
20
|
<body>
|
13
|
-
|
14
|
-
|
15
|
-
<
|
16
|
-
<
|
17
|
-
|
18
|
-
<
|
19
|
-
|
20
|
-
<
|
21
|
-
<
|
22
|
-
<
|
23
|
-
<
|
24
|
-
|
25
|
-
<
|
26
|
-
<
|
27
|
-
|
28
|
-
<
|
29
|
-
<
|
30
|
-
|
31
|
-
|
32
|
-
<
|
33
|
-
|
34
|
-
<p> <button onclick="registerWebView();">AdSense Register</button></p>
|
35
|
-
<p> <button onclick="loadUrl();">AdSense load Url</button></p>
|
36
|
-
|
37
|
-
<p> <button onclick="cleanText();">Clean response Text</button></p>
|
38
|
-
|
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>
|
39
42
|
</body>
|
40
43
|
</html>
|
@@ -10,15 +10,30 @@ function loadBanner() {
|
|
10
10
|
|
11
11
|
if (typeof cordova !== 'undefined') {
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
// IOS Still under development
|
14
|
+
if (isPlatformIOS){
|
15
|
+
// If there is a problem isOverlapping: false
|
16
|
+
cordova.plugins.emiAdmobPlugin.styleBannerAd({
|
17
|
+
isOverlapping: true, // default false IOS | Android
|
18
|
+
paddingWebView: 1.0 // Only IOS
|
19
|
+
});
|
20
|
+
|
21
|
+
} else {
|
22
|
+
|
23
|
+
// Android
|
24
|
+
|
25
|
+
cordova.plugins.emiAdmobPlugin.styleBannerAd({
|
15
26
|
isOverlapping: true, // default false IOS | Android
|
16
27
|
isStatusBarShow: true, // default true Only Android
|
17
|
-
paddingWebView: 1.0, // Only IOS > padding banner Container and webView Container
|
18
28
|
overlappingHeight: 0, // default 0 (Automatic) Only Android
|
19
29
|
padding: 0, // default 0 Only Android
|
20
30
|
margins: 0 // default 0 (Automatic) Only Android
|
21
31
|
});
|
32
|
+
|
33
|
+
|
34
|
+
}
|
35
|
+
|
36
|
+
|
22
37
|
|
23
38
|
|
24
39
|
|
@@ -26,7 +41,7 @@ function loadBanner() {
|
|
26
41
|
adUnitId: Banner_ID, //Banner_ID,
|
27
42
|
position: "bottom-center", // "Recommended: bottom-center"
|
28
43
|
size: "banner", // autoResize: true (only responsive_adaptive)
|
29
|
-
collapsible: "
|
44
|
+
collapsible: "", // position: top | bottom (disable, empty string)
|
30
45
|
autoResize: true, // default false
|
31
46
|
autoShow: true, // default false
|
32
47
|
|
@@ -143,7 +158,7 @@ on.banner.hide
|
|
143
158
|
// This is only triggered when cordova.plugins.emiAdmobPlugin.styleBannerAd
|
144
159
|
document.addEventListener('on.style.banner.ad', (data) => {
|
145
160
|
console.log("on.style.banner.ad: " + JSON.stringify(data));
|
146
|
-
/*
|
161
|
+
/* (ANDROID)
|
147
162
|
const navBarHeight = data.navBarHeight;
|
148
163
|
const screenHeight = data.screenHeight;
|
149
164
|
const usableHeight = data.usableHeight;
|
@@ -153,8 +168,12 @@ document.addEventListener('on.style.banner.ad', (data) => {
|
|
153
168
|
const marginsInPx = data.marginsInPx;
|
154
169
|
*/
|
155
170
|
|
156
|
-
|
157
|
-
|
171
|
+
/* (IOS)
|
172
|
+
const screenHeight = data.screenHeight;
|
173
|
+
const screenWidth = data.screenWidth;
|
174
|
+
const safeAreaTop = data.safeAreaTop;
|
175
|
+
const safeAreaBottom = data.safeAreaBottom;
|
176
|
+
*/
|
158
177
|
|
159
178
|
});
|
160
179
|
|
@@ -77,20 +77,20 @@ 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
|
}
|
84
84
|
|
85
85
|
|
86
|
-
// (Optional)
|
87
|
-
|
86
|
+
// (Optional IOS | ANDROID)
|
87
|
+
// Documentation: https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/54
|
88
|
+
/*
|
88
89
|
cordova.plugins.emiAdmobPlugin.metaData({
|
89
90
|
|
90
|
-
useCustomConsentManager: false, // deactivate Google's consent Default false
|
91
|
-
|
92
|
-
|
93
|
-
setKeyword: "" // https://github.com/EMI-INDO/emi-indo-cordova-plugin-admob/discussions/54
|
91
|
+
useCustomConsentManager: false, // deactivate Google's consent Default false (IOS | ANDROID)
|
92
|
+
isEnabledKeyword: false, // Default false (IOS | ANDROID)
|
93
|
+
setKeyword: "" // string separated by commas without spaces (IOS | ANDROID)
|
94
94
|
|
95
95
|
});
|
96
96
|
*/
|
@@ -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;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
function showPrivacyOptionsForm() {
|
5
|
+
|
6
|
+
if (typeof cordova !== 'undefined') {
|
7
|
+
cordova.plugins.emiAdmobPlugin.showPrivacyOptionsForm(); // IOS | Android
|
8
|
+
}
|
9
|
+
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
/*
|
16
|
+
There is a method to force the show Privacy Options Form
|
17
|
+
|
18
|
+
NOTE forceDisplayPrivacyForm
|
19
|
+
|
20
|
+
This method is not recommended, as no matter what country the form is in, it will still be displayed.
|
21
|
+
So this method must be called with an on-click, so that it is not triggered continuously.
|
22
|
+
use this method wisely.
|
23
|
+
|
24
|
+
*/
|
25
|
+
|
26
|
+
|
27
|
+
function forceDisplayPrivacyForm() {
|
28
|
+
|
29
|
+
if (typeof cordova !== 'undefined') {
|
30
|
+
cordova.plugins.emiAdmobPlugin.forceDisplayPrivacyForm(); // Only IOS
|
31
|
+
}
|
32
|
+
|
33
|
+
}
|
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.h
CHANGED
@@ -25,6 +25,7 @@
|
|
25
25
|
- (void)showPrivacyOptionsForm:(CDVInvokedUrlCommand *)command;
|
26
26
|
- (void)forceDisplayPrivacyForm:(CDVInvokedUrlCommand *)command;
|
27
27
|
- (void)consentReset:(CDVInvokedUrlCommand *)command;
|
28
|
+
- (void)metaData:(CDVInvokedUrlCommand *)command;
|
28
29
|
- (void)getIabTfc:(CDVInvokedUrlCommand *)command;
|
29
30
|
- (void)loadAppOpenAd:(CDVInvokedUrlCommand *)command;
|
30
31
|
- (void)showAppOpenAd:(CDVInvokedUrlCommand *)command;
|
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;
|
@@ -25,6 +26,8 @@ BOOL auto_Show = NO;
|
|
25
26
|
NSString *setPosition = @"bottom-center"; // Default
|
26
27
|
NSString *bannerSaveAdUnitId = @""; // autoResize dependency = true
|
27
28
|
|
29
|
+
|
30
|
+
|
28
31
|
BOOL isCollapsible = NO;
|
29
32
|
BOOL isAutoResize = NO;
|
30
33
|
|
@@ -41,6 +44,11 @@ BOOL isResponseInfo = NO;
|
|
41
44
|
BOOL isUsingAdManagerRequest = YES;
|
42
45
|
|
43
46
|
|
47
|
+
BOOL isCustomConsentManager = NO;
|
48
|
+
BOOL isEnabledKeyword = NO;
|
49
|
+
NSString *setKeyword = @"";
|
50
|
+
|
51
|
+
|
44
52
|
- (BOOL)canRequestAds {
|
45
53
|
return UMPConsentInformation.sharedInstance.canRequestAds;
|
46
54
|
}
|
@@ -48,6 +56,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
48
56
|
isUsingAdManagerRequest = value;
|
49
57
|
}
|
50
58
|
|
59
|
+
|
51
60
|
- (void)setAdRequest {
|
52
61
|
if (isUsingAdManagerRequest) {
|
53
62
|
self.globalRequest = [GAMRequest request];
|
@@ -56,9 +65,27 @@ BOOL isUsingAdManagerRequest = YES;
|
|
56
65
|
self.globalRequest = [GADRequest request];
|
57
66
|
NSLog(@"Using AdMob request");
|
58
67
|
}
|
68
|
+
|
69
|
+
if (isEnabledKeyword && setKeyword.length > 0) {
|
70
|
+
NSArray *keywords = [setKeyword componentsSeparatedByString:@","];
|
71
|
+
for (NSString *keyword in keywords) {
|
72
|
+
NSString *trimmedKeyword = [keyword stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
73
|
+
if (trimmedKeyword.length > 0) {
|
74
|
+
NSLog(@"Adding keyword: %@", trimmedKeyword);
|
75
|
+
[self.globalRequest setKeywords:[self.globalRequest.keywords arrayByAddingObject:trimmedKeyword]];
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
59
80
|
}
|
60
81
|
|
61
82
|
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
62
89
|
- (void)isResponseInfo:(BOOL)value {
|
63
90
|
isResponseInfo = value;
|
64
91
|
}
|
@@ -76,12 +103,19 @@ BOOL isUsingAdManagerRequest = YES;
|
|
76
103
|
[self setUsingAdManagerRequest:setAdRequest];
|
77
104
|
[self isResponseInfo:responseInfo];
|
78
105
|
[self isDebugGeography:setDebugGeography];
|
106
|
+
|
107
|
+
if (isCustomConsentManager) {
|
108
|
+
[self startGoogleMobileAdsSDK];
|
109
|
+
[self fireEvent:@"" event:@"on.custom.consent.manager.used" withData:nil];
|
110
|
+
return;
|
111
|
+
}
|
79
112
|
|
80
113
|
__block CDVPluginResult *pluginResult;
|
81
114
|
NSString *callbackId = command.callbackId;
|
82
115
|
NSString *deviceId = [self __getAdMobDeviceId];
|
83
116
|
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
|
84
|
-
|
117
|
+
|
118
|
+
|
85
119
|
if (setDebugGeography) {
|
86
120
|
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
|
87
121
|
parameters.debugSettings = debugSettings;
|
@@ -144,35 +178,41 @@ BOOL isUsingAdManagerRequest = YES;
|
|
144
178
|
|
145
179
|
|
146
180
|
- (void)requestIDFA:(CDVInvokedUrlCommand *)command {
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
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
|
+
}
|
174
211
|
}
|
175
212
|
|
213
|
+
|
214
|
+
|
215
|
+
|
176
216
|
- (void)startGoogleMobileAdsSDK {
|
177
217
|
static dispatch_once_t onceToken;
|
178
218
|
dispatch_once(&onceToken, ^{
|
@@ -330,6 +370,10 @@ BOOL isUsingAdManagerRequest = YES;
|
|
330
370
|
|
331
371
|
|
332
372
|
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
333
377
|
- (BOOL)isPrivacyOptionsRequired {
|
334
378
|
UMPPrivacyOptionsRequirementStatus status = UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus;
|
335
379
|
|
@@ -526,7 +570,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
526
570
|
[self.bannerViewLayout.trailingAnchor
|
527
571
|
constraintEqualToAnchor:rootView.trailingAnchor]
|
528
572
|
.active = YES;
|
529
|
-
|
573
|
+
[self.bannerViewLayout.heightAnchor constraintEqualToConstant:bannerHeightFinal]
|
530
574
|
.active = YES;
|
531
575
|
}
|
532
576
|
|
@@ -540,9 +584,21 @@ BOOL isUsingAdManagerRequest = YES;
|
|
540
584
|
|
541
585
|
[self.bannerViewLayout addSubview:self.bannerView];
|
542
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
|
+
}
|
543
599
|
|
544
600
|
} @catch (NSException *exception) {
|
545
|
-
|
601
|
+
NSLog(@"Exception: %@", exception.reason);
|
546
602
|
}
|
547
603
|
});
|
548
604
|
}
|
@@ -588,7 +644,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
588
644
|
|
589
645
|
if (adFormat == 5) {
|
590
646
|
dispatch_async(dispatch_get_main_queue(), ^{
|
591
|
-
UIView *parentView =
|
647
|
+
UIView *parentView = self.viewController.view;
|
592
648
|
CGRect frame = self.bannerView.frame;
|
593
649
|
|
594
650
|
if (@available(iOS 11.0, *)) {
|
@@ -618,8 +674,10 @@ BOOL isUsingAdManagerRequest = YES;
|
|
618
674
|
self.bannerView.delegate = self;
|
619
675
|
[self.bannerView loadRequest:self.globalRequest];
|
620
676
|
self.bannerView.hidden = YES;
|
621
|
-
[parentView
|
622
|
-
|
677
|
+
if (![parentView.subviews containsObject:self.bannerView]) {
|
678
|
+
[parentView addSubview:self.bannerView];
|
679
|
+
[parentView bringSubviewToFront:self.bannerView];
|
680
|
+
}
|
623
681
|
});
|
624
682
|
|
625
683
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
@@ -632,164 +690,158 @@ BOOL isUsingAdManagerRequest = YES;
|
|
632
690
|
}
|
633
691
|
|
634
692
|
|
635
|
-
|
636
693
|
- (void)showBannerAd:(CDVInvokedUrlCommand *)command {
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
694
|
+
@try {
|
695
|
+
if (self.bannerView) {
|
696
|
+
self.bannerView.hidden = NO;
|
697
|
+
if (isSetOverlapping){
|
698
|
+
[self setBodyHeight:command];
|
699
|
+
}
|
700
|
+
|
701
|
+
} else {
|
702
|
+
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
703
|
+
}
|
704
|
+
}
|
705
|
+
@catch (NSException *exception) {
|
706
|
+
NSLog(@"[AdPlugin] Error in showBannerAd: %@", exception.reason);
|
707
|
+
}
|
648
708
|
}
|
649
709
|
|
650
|
-
- (void)addBannerViewToView:(CDVInvokedUrlCommand *)command {
|
651
|
-
bannerView.translatesAutoresizingMaskIntoConstraints = NO;
|
652
|
-
[self.viewController.view addSubview:bannerView];
|
653
|
-
if ([setPosition isEqualToString:@"bottom-center"]) {
|
654
|
-
[self.viewController.view addConstraints:@[
|
655
|
-
[NSLayoutConstraint
|
656
|
-
constraintWithItem:bannerView
|
657
|
-
attribute:NSLayoutAttributeBottom
|
658
|
-
relatedBy:NSLayoutRelationEqual
|
659
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
660
|
-
attribute:NSLayoutAttributeBottom
|
661
|
-
multiplier:1
|
662
|
-
constant:0],
|
663
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
664
|
-
attribute:NSLayoutAttributeCenterX
|
665
|
-
relatedBy:NSLayoutRelationEqual
|
666
|
-
toItem:self.viewController.view
|
667
|
-
attribute:NSLayoutAttributeCenterX
|
668
|
-
multiplier:1
|
669
|
-
constant:0]
|
670
|
-
]];
|
671
|
-
} else if ([setPosition isEqualToString:@"top-center"]) {
|
672
|
-
|
673
|
-
[self.viewController.view addConstraints:@[
|
674
|
-
[NSLayoutConstraint
|
675
|
-
constraintWithItem:bannerView
|
676
|
-
attribute:NSLayoutAttributeTop
|
677
|
-
relatedBy:NSLayoutRelationEqual
|
678
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
679
|
-
attribute:NSLayoutAttributeTop
|
680
|
-
multiplier:1
|
681
|
-
constant:0],
|
682
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
683
|
-
attribute:NSLayoutAttributeCenterX
|
684
|
-
relatedBy:NSLayoutRelationEqual
|
685
|
-
toItem:self.viewController.view
|
686
|
-
attribute:NSLayoutAttributeCenterX
|
687
|
-
multiplier:1
|
688
|
-
constant:0]
|
689
|
-
]];
|
690
710
|
|
691
|
-
|
692
|
-
[
|
693
|
-
|
694
|
-
|
695
|
-
attribute:NSLayoutAttributeBottom
|
696
|
-
relatedBy:NSLayoutRelationEqual
|
697
|
-
toItem:self.viewController.view.safeAreaLayoutGuide
|
698
|
-
attribute:NSLayoutAttributeTop
|
699
|
-
multiplier:1
|
700
|
-
constant:0],
|
701
|
-
[NSLayoutConstraint constraintWithItem:bannerView
|
702
|
-
attribute:NSLayoutAttributeCenterX
|
703
|
-
relatedBy:NSLayoutRelationEqual
|
704
|
-
toItem:self.viewController.view
|
705
|
-
attribute:NSLayoutAttributeCenterX
|
706
|
-
multiplier:1
|
707
|
-
constant:0]
|
708
|
-
]];
|
709
|
-
}
|
710
|
-
[self bannerOverlapping];
|
711
|
-
}
|
711
|
+
- (UIView*)findWebViewInView:(UIView*)view {
|
712
|
+
if ([view isKindOfClass:NSClassFromString(@"WKWebView")] || [view isKindOfClass:NSClassFromString(@"UIWebView")]) {
|
713
|
+
return view;
|
714
|
+
}
|
712
715
|
|
716
|
+
for (UIView* subview in view.subviews) {
|
717
|
+
UIView* found = [self findWebViewInView:subview];
|
718
|
+
if (found) {
|
719
|
+
return found;
|
720
|
+
}
|
721
|
+
}
|
713
722
|
|
723
|
+
return nil;
|
724
|
+
}
|
714
725
|
|
715
726
|
|
727
|
+
- (void)setBodyHeight:(CDVInvokedUrlCommand*)command {
|
728
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
729
|
+
@try {
|
716
730
|
|
717
|
-
|
718
|
-
|
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 {
|
731
|
+
UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
|
732
|
+
UIViewController* rootViewController = keyWindow.rootViewController;
|
727
733
|
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
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);
|
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;
|
781
738
|
}
|
782
739
|
|
783
|
-
|
784
|
-
|
740
|
+
|
741
|
+
[rootViewController.view setNeedsLayout];
|
742
|
+
[rootViewController.view layoutIfNeeded];
|
743
|
+
|
744
|
+
UIEdgeInsets safeAreaInsets = rootViewController.view.safeAreaInsets;
|
745
|
+
|
746
|
+
if (safeAreaInsets.bottom == 0) {
|
747
|
+
safeAreaInsets = keyWindow.safeAreaInsets;
|
748
|
+
}
|
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
|
+
});
|
785
827
|
}
|
786
828
|
|
787
829
|
|
788
830
|
|
831
|
+
- (void)metaData:(CDVInvokedUrlCommand *)command {
|
832
|
+
NSDictionary *options = [command.arguments objectAtIndex:0];
|
833
|
+
BOOL useCustomConsentManager = [[options valueForKey:@"useCustomConsentManager"] boolValue];
|
834
|
+
BOOL useCustomKeyword = [[options valueForKey:@"isEnabledKeyword"] boolValue];
|
835
|
+
NSString *keywordValue = [options valueForKey:@"setKeyword"];
|
789
836
|
|
837
|
+
isCustomConsentManager = useCustomConsentManager;
|
838
|
+
isEnabledKeyword = useCustomKeyword;
|
839
|
+
setKeyword = keywordValue;
|
840
|
+
|
841
|
+
}
|
790
842
|
|
791
|
-
- (void)styleBannerAd:(CDVInvokedUrlCommand *)command {
|
792
843
|
|
844
|
+
- (void)styleBannerAd:(CDVInvokedUrlCommand *)command {
|
793
845
|
NSDictionary *options = [command.arguments objectAtIndex:0];
|
794
846
|
BOOL isOverlapping = [[options valueForKey:@"isOverlapping"] boolValue];
|
795
847
|
CGFloat paddingContainer = [[options valueForKey:@"paddingWebView"] floatValue];
|
@@ -797,9 +849,57 @@ BOOL isUsingAdManagerRequest = YES;
|
|
797
849
|
isSetOverlapping = isOverlapping;
|
798
850
|
paddingWebView = paddingContainer;
|
799
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
|
+
});
|
800
899
|
}
|
801
900
|
|
802
901
|
|
902
|
+
|
803
903
|
- (GADAdSize)__AdSizeFromString:(NSString *)size {
|
804
904
|
|
805
905
|
if (self.viewWidth == 0) {
|
@@ -828,34 +928,48 @@ BOOL isUsingAdManagerRequest = YES;
|
|
828
928
|
|
829
929
|
|
830
930
|
|
931
|
+
- (void)resetWebViewHeight {
|
932
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
933
|
+
UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
|
934
|
+
UIViewController *rootViewController = keyWindow.rootViewController;
|
831
935
|
|
936
|
+
if (!rootViewController) {
|
937
|
+
NSLog(@"[CordovaBodyHeight] Root ViewController not found on reset");
|
938
|
+
return;
|
939
|
+
}
|
832
940
|
|
833
|
-
|
834
|
-
if (!self.webView) {
|
835
|
-
NSLog(@"[AdPlugin] Error: WebView is missing. Reset skipped.");
|
836
|
-
return;
|
837
|
-
}
|
941
|
+
UIEdgeInsets safeAreaInsets = rootViewController.view.safeAreaInsets;
|
838
942
|
|
839
|
-
|
840
|
-
|
943
|
+
if (safeAreaInsets.bottom == 0) {
|
944
|
+
safeAreaInsets = keyWindow.safeAreaInsets;
|
945
|
+
}
|
841
946
|
|
842
|
-
|
947
|
+
CGFloat screenHeight = UIScreen.mainScreen.bounds.size.height;
|
843
948
|
|
844
|
-
|
845
|
-
|
846
|
-
|
949
|
+
CGRect contentFrame = rootViewController.view.frame;
|
950
|
+
contentFrame.origin.y = 0;
|
951
|
+
contentFrame.size.height = screenHeight - safeAreaInsets.bottom;
|
952
|
+
rootViewController.view.frame = contentFrame;
|
847
953
|
|
848
|
-
|
849
|
-
|
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;
|
850
960
|
|
851
|
-
}
|
852
|
-
NSLog(@"[
|
961
|
+
} else {
|
962
|
+
NSLog(@"[CordovaBodyHeight] WebView not found on reset");
|
853
963
|
}
|
964
|
+
|
965
|
+
[rootViewController.view setNeedsLayout];
|
966
|
+
[rootViewController.view layoutIfNeeded];
|
854
967
|
});
|
855
968
|
}
|
856
969
|
|
857
970
|
|
858
971
|
|
972
|
+
|
859
973
|
- (void)hideBannerAd:(CDVInvokedUrlCommand *)command {
|
860
974
|
CDVPluginResult *pluginResult;
|
861
975
|
NSString *callbackId = command.callbackId;
|
@@ -871,6 +985,9 @@ BOOL isUsingAdManagerRequest = YES;
|
|
871
985
|
}
|
872
986
|
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
873
987
|
}
|
988
|
+
|
989
|
+
|
990
|
+
|
874
991
|
- (void)removeBannerAd:(CDVInvokedUrlCommand *)command {
|
875
992
|
CDVPluginResult *pluginResult;
|
876
993
|
NSString *callbackId = command.callbackId;
|
@@ -879,8 +996,8 @@ BOOL isUsingAdManagerRequest = YES;
|
|
879
996
|
self.bannerView.hidden = YES;
|
880
997
|
[self.bannerView removeFromSuperview];
|
881
998
|
self.bannerView = nil;
|
882
|
-
|
883
|
-
|
999
|
+
[self resetWebViewHeight];
|
1000
|
+
[self fireEvent:@"" event:@"on.banner.remove" withData:nil];
|
884
1001
|
});
|
885
1002
|
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
886
1003
|
} else {
|
@@ -1600,8 +1717,10 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1600
1717
|
[self fireEvent:@"" event:@"on.banner.load" withData:bannerLoadJsonString];
|
1601
1718
|
|
1602
1719
|
if (auto_Show && self.bannerView) {
|
1603
|
-
|
1604
|
-
|
1720
|
+
if (isSetOverlapping){
|
1721
|
+
self.bannerView.hidden = NO;
|
1722
|
+
[self setBodyHeight:command];
|
1723
|
+
}
|
1605
1724
|
} else {
|
1606
1725
|
[self fireEvent:@"" event:@"on.banner.failed.show" withData:nil];
|
1607
1726
|
}
|
@@ -1686,7 +1805,6 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1686
1805
|
}
|
1687
1806
|
}
|
1688
1807
|
|
1689
|
-
|
1690
1808
|
- (void)bannerViewDidRecordImpression:(GADBannerView *)bannerView {
|
1691
1809
|
[self fireEvent:@"" event:@"on.banner.impression" withData:nil];
|
1692
1810
|
}
|
@@ -1701,6 +1819,7 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1701
1819
|
|
1702
1820
|
- (void)bannerViewDidDismissScreen:(GADBannerView *)bannerView {
|
1703
1821
|
[self fireEvent:@"" event:@"on.banner.did.dismiss" withData:nil];
|
1822
|
+
|
1704
1823
|
}
|
1705
1824
|
|
1706
1825
|
#pragma mark GADFullScreeContentDelegate implementation
|
@@ -1779,3 +1898,4 @@ BOOL isUsingAdManagerRequest = YES;
|
|
1779
1898
|
object:nil];
|
1780
1899
|
}
|
1781
1900
|
@end
|
1901
|
+
|