Skip to content

Commit b48e02f

Browse files
committed
fix iOS 10 build
1 parent 27e6c67 commit b48e02f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/ios/CDVWKInAppBrowser.m

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,15 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
145145
}
146146

147147
if (browserOptions.clearcache) {
148+
bool isAtLeastiOS11 = false;
149+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
148150
if (@available(iOS 11.0, *)) {
151+
isAtLeastiOS11 = true;
152+
}
153+
#endif
154+
155+
if(isAtLeastiOS11){
156+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
149157
// Deletes all cookies
150158
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
151159
[cookieStore getAllCookies:^(NSArray* cookies) {
@@ -154,6 +162,7 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
154162
[cookieStore deleteCookie:cookie completionHandler:nil];
155163
}
156164
}];
165+
#endif
157166
}else{
158167
// https://stackoverflow.com/a/31803708/777265
159168
// Only deletes domain cookies (not session cookies)
@@ -172,7 +181,14 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
172181
}
173182

174183
if (browserOptions.clearsessioncache) {
184+
bool isAtLeastiOS11 = false;
185+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
175186
if (@available(iOS 11.0, *)) {
187+
isAtLeastiOS11 = true;
188+
}
189+
#endif
190+
if (isAtLeastiOS11) {
191+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
176192
// Deletes session cookies
177193
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
178194
[cookieStore getAllCookies:^(NSArray* cookies) {
@@ -183,11 +199,12 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
183199
}
184200
}
185201
}];
202+
#endif
186203
}else{
187204
NSLog(@"clearsessioncache not available below iOS 11.0");
188205
}
189206
}
190-
207+
191208
if (self.inAppBrowserViewController == nil) {
192209
NSString* userAgent = [CDVUserAgentUtil originalUserAgent];
193210
NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"];

0 commit comments

Comments
 (0)