diff --git a/ios/RCTWKWebView/RCTWKWebView.m b/ios/RCTWKWebView/RCTWKWebView.m index e5b73277..72853cc9 100644 --- a/ios/RCTWKWebView/RCTWKWebView.m +++ b/ios/RCTWKWebView/RCTWKWebView.m @@ -360,6 +360,18 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView #pragma mark - WKNavigationDelegate methods +- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler { + if (_sendCookies) { + NSHTTPURLResponse *response = (NSHTTPURLResponse *)navigationResponse.response; + NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[response allHeaderFields] forURL:response.URL]; + for (NSHTTPCookie *cookie in cookies) { + [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie]; + } + } + + decisionHandler(WKNavigationResponsePolicyAllow); +} + #if DEBUG - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposit ion, NSURLCredential * _Nullable))completionHandler { NSURLCredential * credential = [[NSURLCredential alloc] initWithTrust:[challenge protectionSpace].serverTrust];