From de1e6b65731e3cb795191e519bcacbbe17fb2bce Mon Sep 17 00:00:00 2001 From: Salakar Date: Tue, 20 Nov 2018 11:40:49 +0000 Subject: [PATCH] [ios] add `enableCache` prop support --- ios/RNCWKWebView.h | 1 + ios/RNCWKWebView.m | 3 +++ ios/RNCWKWebViewManager.m | 1 + 3 files changed, 5 insertions(+) diff --git a/ios/RNCWKWebView.h b/ios/RNCWKWebView.h index ea15bda..aaab22f 100644 --- a/ios/RNCWKWebView.h +++ b/ios/RNCWKWebView.h @@ -38,6 +38,7 @@ shouldStartLoadForRequest:(NSMutableDictionary *)request @property (nonatomic, assign) BOOL hideKeyboardAccessoryView; @property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures; @property (nonatomic, copy) NSString *userAgent; +@property (nonatomic, assign) BOOL enableCache; - (void)postMessage:(NSString *)message; - (void)injectJavaScript:(NSString *)script; diff --git a/ios/RNCWKWebView.m b/ios/RNCWKWebView.m index 7afe599..82f722d 100644 --- a/ios/RNCWKWebView.m +++ b/ios/RNCWKWebView.m @@ -94,6 +94,9 @@ static NSString *const MessageHanderName = @"ReactNative"; }; WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new]; + if (_enableCache) { + wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore defaultDataStore]; + } wkWebViewConfig.userContentController = [WKUserContentController new]; [wkWebViewConfig.userContentController addScriptMessageHandler: self name: MessageHanderName]; wkWebViewConfig.allowsInlineMediaPlayback = _allowsInlineMediaPlayback; diff --git a/ios/RNCWKWebViewManager.m b/ios/RNCWKWebViewManager.m index 2a1ce3a..7455b39 100644 --- a/ios/RNCWKWebViewManager.m +++ b/ios/RNCWKWebViewManager.m @@ -46,6 +46,7 @@ RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL) RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL) RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL) RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString) +RCT_EXPORT_VIEW_PROPERTY(enableCache, BOOL) /** * Expose methods to enable messaging the webview.