From b48e02fcd5298c56f000e716f5492f7dc7ab73f1 Mon Sep 17 00:00:00 2001 From: Dave Alden Date: Sun, 30 Sep 2018 08:03:16 +0100 Subject: [PATCH] fix iOS 10 build --- src/ios/CDVWKInAppBrowser.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 4d59bc2..9b515dd 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -145,7 +145,15 @@ static CDVWKInAppBrowser* instance = nil; } 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) { @@ -154,6 +162,7 @@ static CDVWKInAppBrowser* instance = nil; [cookieStore deleteCookie:cookie completionHandler:nil]; } }]; +#endif }else{ // https://stackoverflow.com/a/31803708/777265 // Only deletes domain cookies (not session cookies) @@ -172,7 +181,14 @@ static CDVWKInAppBrowser* instance = nil; } 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) { @@ -183,11 +199,12 @@ static CDVWKInAppBrowser* instance = nil; } } }]; +#endif }else{ NSLog(@"clearsessioncache not available below iOS 11.0"); } } - + if (self.inAppBrowserViewController == nil) { NSString* userAgent = [CDVUserAgentUtil originalUserAgent]; NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"];