Skip to content

Commit

Permalink
fix iOS 10 build
Browse files Browse the repository at this point in the history
  • Loading branch information
dpa99c committed Sep 30, 2018
1 parent 27e6c67 commit b48e02f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/ios/CDVWKInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,15 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
}

if (browserOptions.clearcache) {
bool isAtLeastiOS11 = false;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
if (@available(iOS 11.0, *)) {
isAtLeastiOS11 = true;
}
#endif

if(isAtLeastiOS11){
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
// Deletes all cookies
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
[cookieStore getAllCookies:^(NSArray* cookies) {
Expand All @@ -154,6 +162,7 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
[cookieStore deleteCookie:cookie completionHandler:nil];
}
}];
#endif
}else{
// https://stackoverflow.com/a/31803708/777265
// Only deletes domain cookies (not session cookies)
Expand All @@ -172,7 +181,14 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
}

if (browserOptions.clearsessioncache) {
bool isAtLeastiOS11 = false;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
if (@available(iOS 11.0, *)) {
isAtLeastiOS11 = true;
}
#endif
if (isAtLeastiOS11) {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
// Deletes session cookies
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
[cookieStore getAllCookies:^(NSArray* cookies) {
Expand All @@ -183,11 +199,12 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
}
}
}];
#endif
}else{
NSLog(@"clearsessioncache not available below iOS 11.0");
}
}

if (self.inAppBrowserViewController == nil) {
NSString* userAgent = [CDVUserAgentUtil originalUserAgent];
NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"];
Expand Down

0 comments on commit b48e02f

Please sign in to comment.