Просмотр исходного кода

fix(iOS): sync cookies obtained in WKWebView to sharedHTTPCookieStorage

Erik Haider Forsén 4 лет назад
Родитель
Сommit
0304d480e8
1 измененных файлов: 7 добавлений и 0 удалений
  1. 7
    0
      ios/RNCWebView.m

+ 7
- 0
ios/RNCWebView.m Просмотреть файл

@@ -1190,6 +1190,13 @@ static NSDictionary* customCertificatesForHost;
1190 1190
       for (NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
1191 1191
         [wkWebViewConfig.websiteDataStore.httpCookieStore setCookie:cookie completionHandler:nil];
1192 1192
       }
1193
+        
1194
+      // Write all cookies from WKWebView back to sharedHTTPCookieStorage
1195
+      [wkWebViewConfig.websiteDataStore.httpCookieStore getAllCookies:^(NSArray* cookies) {
1196
+        for (NSHTTPCookie *cookie in cookies) {
1197
+          [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
1198
+        }
1199
+      }];
1193 1200
     } else {
1194 1201
       NSMutableString *script = [NSMutableString string];
1195 1202