fix(ios): Make allowFileAccessFromFileURLs work in iOS. (#1061)
This commit is contained in:
parent
604495e399
commit
88b64981f4
|
@ -686,11 +686,11 @@ Boolean value to control whether DOM Storage is enabled. Used only in Android.
|
||||||
|
|
||||||
### `javaScriptEnabled`
|
### `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 |
|
| Type | Required |
|
||||||
| ---- | -------- | -------- |
|
| ---- | -------- |
|
||||||
| bool | No | Android |
|
| 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`.
|
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 |
|
| Type | Required |
|
||||||
| ---- | -------- | -------- |
|
| ---- | -------- |
|
||||||
| bool | No | Android |
|
| bool | No |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
@property (nonatomic, copy) NSString * _Nullable applicationNameForUserAgent;
|
@property (nonatomic, copy) NSString * _Nullable applicationNameForUserAgent;
|
||||||
@property (nonatomic, assign) BOOL cacheEnabled;
|
@property (nonatomic, assign) BOOL cacheEnabled;
|
||||||
@property (nonatomic, assign) BOOL javaScriptEnabled;
|
@property (nonatomic, assign) BOOL javaScriptEnabled;
|
||||||
|
@property (nonatomic, assign) BOOL allowFileAccessFromFileURLs;
|
||||||
@property (nonatomic, assign) BOOL allowsLinkPreview;
|
@property (nonatomic, assign) BOOL allowsLinkPreview;
|
||||||
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
|
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
|
||||||
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
|
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
|
||||||
|
|
|
@ -138,8 +138,16 @@ static NSDictionary* customCertificatesForHost;
|
||||||
if (self.window != nil && _webView == nil) {
|
if (self.window != nil && _webView == nil) {
|
||||||
WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
|
WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
|
||||||
WKPreferences *prefs = [[WKPreferences alloc]init];
|
WKPreferences *prefs = [[WKPreferences alloc]init];
|
||||||
|
BOOL _prefsUsed = NO;
|
||||||
if (!_javaScriptEnabled) {
|
if (!_javaScriptEnabled) {
|
||||||
prefs.javaScriptEnabled = NO;
|
prefs.javaScriptEnabled = NO;
|
||||||
|
_prefsUsed = YES;
|
||||||
|
}
|
||||||
|
if (_allowFileAccessFromFileURLs) {
|
||||||
|
[prefs setValue:@TRUE forKey:@"allowFileAccessFromFileURLs"];
|
||||||
|
_prefsUsed = YES;
|
||||||
|
}
|
||||||
|
if (_prefsUsed) {
|
||||||
wkWebViewConfig.preferences = prefs;
|
wkWebViewConfig.preferences = prefs;
|
||||||
}
|
}
|
||||||
if (_incognito) {
|
if (_incognito) {
|
||||||
|
|
|
@ -53,6 +53,7 @@ RCT_EXPORT_VIEW_PROPERTY(onContentProcessDidTerminate, RCTDirectEventBlock)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
|
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptBeforeContentLoaded, NSString)
|
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScriptBeforeContentLoaded, NSString)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(javaScriptEnabled, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(javaScriptEnabled, BOOL)
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(allowFileAccessFromFileURLs, BOOL)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(allowsInlineMediaPlayback, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(allowsInlineMediaPlayback, BOOL)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, BOOL)
|
||||||
#if WEBKIT_IOS_10_APIS_AVAILABLE
|
#if WEBKIT_IOS_10_APIS_AVAILABLE
|
||||||
|
|
Loading…
Reference in New Issue