feat(WKWebview): Add incognito prop to iOS WKWebview
Allows the webview to be opened with an ephemeral data storage.
This commit is contained in:
parent
6d64db99ec
commit
62f871c186
|
@ -44,6 +44,7 @@ This document lays out the current public properties and methods for the React N
|
|||
- [`html`](Reference.md#html)
|
||||
- [`hideKeyboardAccessoryView`](Reference.md#hidekeyboardaccessoryview)
|
||||
- [`allowsBackForwardNavigationGestures`](Reference.md#allowsbackforwardnavigationgestures)
|
||||
- [`incognito`](Reference.md#incognito)
|
||||
- [`allowFileAccess`](Reference.md#allowFileAccess)
|
||||
- [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
|
||||
- [`pagingEnabled`](Reference.md#pagingEnabled)
|
||||
|
@ -511,6 +512,16 @@ If true, this will be able horizontal swipe gestures when using the WKWebView. T
|
|||
|
||||
---
|
||||
|
||||
### `incognito`
|
||||
|
||||
Does not store any data within the lifetime of the WebView.
|
||||
|
||||
| Type | Required | Platform |
|
||||
| ------- | -------- | ------------- |
|
||||
| boolean | No | iOS WKWebView |
|
||||
|
||||
---
|
||||
|
||||
### `allowFileAccess`
|
||||
|
||||
If true, this will allow access to the file system via `file://` URI's. The default value is `false`.
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
||||
@property (nonatomic, assign) BOOL hideKeyboardAccessoryView;
|
||||
@property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures;
|
||||
@property (nonatomic, assign) BOOL incognito;
|
||||
@property (nonatomic, assign) BOOL useSharedProcessPool;
|
||||
@property (nonatomic, copy) NSString *userAgent;
|
||||
@property (nonatomic, assign) BOOL allowsLinkPreview;
|
||||
|
|
|
@ -81,6 +81,9 @@ static NSString *const MessageHanderName = @"ReactNative";
|
|||
};
|
||||
|
||||
WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
|
||||
if (_incognito) {
|
||||
wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
|
||||
}
|
||||
if(self.useSharedProcessPool) {
|
||||
wkWebViewConfig.processPool = [[RNCWKProcessPoolManager sharedManager] sharedProcessPool];
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
|
|||
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(hideKeyboardAccessoryView, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
|
||||
|
|
|
@ -168,6 +168,15 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||
'The allowsBackForwardNavigationGestures property is not supported when useWebKit = false',
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!this.props.useWebKit &&
|
||||
this.props.incognito
|
||||
) {
|
||||
console.warn(
|
||||
'The incognito property is not supported when useWebKit = false',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -252,6 +261,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||
}
|
||||
hideKeyboardAccessoryView={this.props.hideKeyboardAccessoryView}
|
||||
allowsBackForwardNavigationGestures={this.props.allowsBackForwardNavigationGestures}
|
||||
incognito={this.props.incognito}
|
||||
userAgent={this.props.userAgent}
|
||||
onLoadingStart={this._onLoadingStart}
|
||||
onLoadingFinish={this._onLoadingFinish}
|
||||
|
@ -443,6 +453,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
|
|||
}
|
||||
|
||||
this._showRedboxOnPropChanges(prevProps, 'allowsInlineMediaPlayback');
|
||||
this._showRedboxOnPropChanges(prevProps, 'incognito');
|
||||
this._showRedboxOnPropChanges(prevProps, 'mediaPlaybackRequiresUserAction');
|
||||
this._showRedboxOnPropChanges(prevProps, 'dataDetectorTypes');
|
||||
|
||||
|
|
|
@ -365,6 +365,11 @@ export type WebViewSharedProps = $ReadOnly<{|
|
|||
*/
|
||||
source?: ?WebViewSource,
|
||||
|
||||
/**
|
||||
* Does not store any data within the lifetime of the WebView.
|
||||
*/
|
||||
incognito?: ?boolean,
|
||||
|
||||
/**
|
||||
* Function that returns a view to show if there's an error.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue