Browse Source

[ios] add `enableCache` prop support

Salakar 6 years ago
parent
commit
de1e6b6573
3 changed files with 5 additions and 0 deletions
  1. 1
    0
      ios/RNCWKWebView.h
  2. 3
    0
      ios/RNCWKWebView.m
  3. 1
    0
      ios/RNCWKWebViewManager.m

+ 1
- 0
ios/RNCWKWebView.h View File

@@ -38,6 +38,7 @@ shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
38 38
 @property (nonatomic, assign) BOOL hideKeyboardAccessoryView;
39 39
 @property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
40 40
 @property (nonatomic, copy) NSString *userAgent;
41
+@property (nonatomic, assign) BOOL enableCache;
41 42
 
42 43
 - (void)postMessage:(NSString *)message;
43 44
 - (void)injectJavaScript:(NSString *)script;

+ 3
- 0
ios/RNCWKWebView.m View File

@@ -94,6 +94,9 @@ static NSString *const MessageHanderName = @"ReactNative";
94 94
     };
95 95
 
96 96
     WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
97
+    if (_enableCache) {
98
+      wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore defaultDataStore];
99
+    }
97 100
     wkWebViewConfig.userContentController = [WKUserContentController new];
98 101
     [wkWebViewConfig.userContentController addScriptMessageHandler: self name: MessageHanderName];
99 102
     wkWebViewConfig.allowsInlineMediaPlayback = _allowsInlineMediaPlayback;

+ 1
- 0
ios/RNCWKWebViewManager.m View File

@@ -46,6 +46,7 @@ RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
46 46
 RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
47 47
 RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
48 48
 RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
49
+RCT_EXPORT_VIEW_PROPERTY(enableCache, BOOL)
49 50
 
50 51
 /**
51 52
  * Expose methods to enable messaging the webview.