chore: logs and comments

This commit is contained in:
Ramo, Davide 2023-09-26 08:59:13 +02:00
parent c80e74f238
commit 9075cc1c18

View File

@ -218,17 +218,19 @@ static CDVWKInAppBrowser* instance = nil;
NSURL* url = [NSURL URLWithString:key]; NSURL* url = [NSURL URLWithString:key];
if(!url){ if(!url){
NSLog(@"Cookie key is not a proper NSURL!"); NSLog(@"Cookie key %@ is not a proper NSURL!",key);
continue; continue;
} }
NSArray<NSHTTPCookie*> *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:@{ @"Set-Cookie" : browserOptions.cookies[key] } forURL:url]; NSArray<NSHTTPCookie*> *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:@{ @"Set-Cookie" : browserOptions.cookies[key] } forURL:url];
if(cookies.count == 0) { if(cookies.count == 0) {
NSLog(@"No cookies to process!"); NSLog(@"No cookies to process for url %@!",url);
} }
for(NSHTTPCookie* cookie in cookies){ for(NSHTTPCookie* cookie in cookies){
//Is not possible to wait for completion because it seems the handler is called after the WKWebView is loaded
//See: https://stackoverflow.com/questions/49452968/wkhttpcookiestore-setcookie-completion-handler-not-called
[cookieStore setCookie:cookie completionHandler:nil]; [cookieStore setCookie:cookie completionHandler:nil];
} }
@ -1164,7 +1166,6 @@ BOOL isExiting = FALSE;
- (void)navigateTo:(NSURL*)url options:(CDVInAppBrowserOptions*)options - (void)navigateTo:(NSURL*)url options:(CDVInAppBrowserOptions*)options
{ {
NSLog(@"options headers: %@", options.headers);
if ([url.scheme isEqualToString:@"file"]) { if ([url.scheme isEqualToString:@"file"]) {
[self.webView loadFileURL:url allowingReadAccessToURL:url]; [self.webView loadFileURL:url allowingReadAccessToURL:url];
} else { } else {
@ -1173,7 +1174,6 @@ BOOL isExiting = FALSE;
NSString* value = options.headers[key]; NSString* value = options.headers[key];
[request setValue:value forHTTPHeaderField:key]; [request setValue:value forHTTPHeaderField:key];
} }
NSLog(@"request headers: %@", request.allHTTPHeaderFields);
[self.webView loadRequest:request]; [self.webView loadRequest:request];
} }
} }