diff --git a/docs/Reference.md b/docs/Reference.md index 773d31a..3ae2348 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -686,11 +686,11 @@ Boolean value to control whether DOM Storage is enabled. Used only in Android. ### `javaScriptEnabled` -Boolean value to enable JavaScript in the `WebView`. Used on Android only as JavaScript is enabled by default on iOS. The default value is `true`. +Boolean value to enable JavaScript in the `WebView`. The default value is `true`. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | Android | +| Type | Required | +| ---- | -------- | +| bool | No | --- @@ -914,9 +914,9 @@ Set whether Geolocation is enabled in the `WebView`. The default value is `false Boolean that sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs. The default value is `false`. -| Type | Required | Platform | -| ---- | -------- | -------- | -| bool | No | Android | +| Type | Required | +| ---- | -------- | +| bool | No | --- diff --git a/ios/RNCWebView.h b/ios/RNCWebView.h index 88e15a9..ed67b4c 100644 --- a/ios/RNCWebView.h +++ b/ios/RNCWebView.h @@ -47,6 +47,7 @@ @property (nonatomic, copy) NSString * _Nullable applicationNameForUserAgent; @property (nonatomic, assign) BOOL cacheEnabled; @property (nonatomic, assign) BOOL javaScriptEnabled; +@property (nonatomic, assign) BOOL allowFileAccessFromFileURLs; @property (nonatomic, assign) BOOL allowsLinkPreview; @property (nonatomic, assign) BOOL showsHorizontalScrollIndicator; @property (nonatomic, assign) BOOL showsVerticalScrollIndicator; diff --git a/ios/RNCWebView.m b/ios/RNCWebView.m index 5620f56..a05a982 100644 --- a/ios/RNCWebView.m +++ b/ios/RNCWebView.m @@ -138,8 +138,16 @@ static NSDictionary* customCertificatesForHost; if (self.window != nil && _webView == nil) { WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new]; WKPreferences *prefs = [[WKPreferences alloc]init]; + BOOL _prefsUsed = NO; if (!_javaScriptEnabled) { prefs.javaScriptEnabled = NO; + _prefsUsed = YES; + } + if (_allowFileAccessFromFileURLs) { + [prefs setValue:@TRUE forKey:@"allowFileAccessFromFileURLs"]; + _prefsUsed = YES; + } + if (_prefsUsed) { wkWebViewConfig.preferences = prefs; } if (_incognito) { diff --git a/ios/RNCWebViewManager.m b/ios/RNCWebViewManager.m index acd2237..7d74468 100644 --- a/ios/RNCWebViewManager.m +++ b/ios/RNCWebViewManager.m @@ -53,6 +53,7 @@ RCT_EXPORT_VIEW_PROPERTY(onContentProcessDidTerminate, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString) RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptBeforeContentLoaded, NSString) RCT_EXPORT_VIEW_PROPERTY(javaScriptEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(allowFileAccessFromFileURLs, BOOL) RCT_EXPORT_VIEW_PROPERTY(allowsInlineMediaPlayback, BOOL) RCT_EXPORT_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, BOOL) #if WEBKIT_IOS_10_APIS_AVAILABLE