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.