mirror of
https://github.com/status-im/react-native-webview.git
synced 2025-02-23 01:08:36 +00:00
feat(ios): Add support for limitsNavigationsToAppBoundDomains
(#1662)
* Add support for iOS-specific prop `limitsNavigationsToAppBoundDomains` * Add check for `limitsNavigationsToAppBoundDomains` property Turns out that @available is simply bugged right now in Xcode and will pretty much always return `true`. Adding a check for the property actually existing as well will avoid iOS <14 crashing horribly. * Improve documentation Co-authored-by: Thibault Malbranche <thibault.malbranche@epitech.eu>
This commit is contained in:
parent
2aa8cee5ee
commit
7decc5cff1
@ -76,6 +76,10 @@
|
|||||||
@property (nonatomic, assign) WKContentMode contentMode;
|
@property (nonatomic, assign) WKContentMode contentMode;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 /* iOS 14 */
|
||||||
|
@property (nonatomic, assign) BOOL limitsNavigationsToAppBoundDomains;
|
||||||
|
#endif
|
||||||
|
|
||||||
+ (void)setClientAuthenticationCredential:(nullable NSURLCredential*)credential;
|
+ (void)setClientAuthenticationCredential:(nullable NSURLCredential*)credential;
|
||||||
+ (void)setCustomCertificatesForHost:(nullable NSDictionary *)certificates;
|
+ (void)setCustomCertificatesForHost:(nullable NSDictionary *)certificates;
|
||||||
- (void)postMessage:(NSString *_Nullable)message;
|
- (void)postMessage:(NSString *_Nullable)message;
|
||||||
|
@ -245,6 +245,16 @@ static NSDictionary* customCertificatesForHost;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 /* iOS 14 */
|
||||||
|
if (@available(iOS 14.0, *)) {
|
||||||
|
if ([wkWebViewConfig respondsToSelector:@selector(limitsNavigationsToAppBoundDomains)]) {
|
||||||
|
if (_limitsNavigationsToAppBoundDomains) {
|
||||||
|
wkWebViewConfig.limitsNavigationsToAppBoundDomains = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Shim the HTML5 history API:
|
// Shim the HTML5 history API:
|
||||||
[wkWebViewConfig.userContentController addScriptMessageHandler:[[RNCWeakScriptMessageDelegate alloc] initWithDelegate:self]
|
[wkWebViewConfig.userContentController addScriptMessageHandler:[[RNCWeakScriptMessageDelegate alloc] initWithDelegate:self]
|
||||||
name:HistoryShimName];
|
name:HistoryShimName];
|
||||||
|
@ -89,6 +89,10 @@ RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustsScrollIndicatorInsets, BOOL)
|
|||||||
RCT_EXPORT_VIEW_PROPERTY(contentMode, WKContentMode)
|
RCT_EXPORT_VIEW_PROPERTY(contentMode, WKContentMode)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 /* iOS 14 */
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(limitsNavigationsToAppBoundDomains, BOOL)
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expose methods to enable messaging the webview.
|
* Expose methods to enable messaging the webview.
|
||||||
*/
|
*/
|
||||||
|
@ -73,6 +73,7 @@ This document lays out the current public properties and methods for the React N
|
|||||||
- [`pullToRefreshEnabled`](Reference.md#pullToRefreshEnabled)
|
- [`pullToRefreshEnabled`](Reference.md#pullToRefreshEnabled)
|
||||||
- [`ignoreSilentHardwareSwitch`](Reference.md#ignoreSilentHardwareSwitch)
|
- [`ignoreSilentHardwareSwitch`](Reference.md#ignoreSilentHardwareSwitch)
|
||||||
- [`onFileDownload`](Reference.md#onFileDownload)
|
- [`onFileDownload`](Reference.md#onFileDownload)
|
||||||
|
- [`limitsNavigationsToAppBoundDomains`](Reference.md#limitsNavigationsToAppBoundDomains)
|
||||||
- [`autoManageStatusBarEnabled`](Reference.md#autoManageStatusBarEnabled)
|
- [`autoManageStatusBarEnabled`](Reference.md#autoManageStatusBarEnabled)
|
||||||
- [`setSupportMultipleWindows`](Reference.md#setSupportMultipleWindows)
|
- [`setSupportMultipleWindows`](Reference.md#setSupportMultipleWindows)
|
||||||
|
|
||||||
@ -1314,6 +1315,25 @@ Example:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### `limitsNavigationsToAppBoundDomains`[⬆](#props-index)<!-- Link generated with jump2header -->
|
||||||
|
|
||||||
|
If true indicates to WebKit that a WKWebView will only navigate to app-bound domains. Only applicable for iOS 14 or greater.
|
||||||
|
|
||||||
|
Once set, any attempt to navigate away from an app-bound domain will fail with the error “App-bound domain failure.”
|
||||||
|
Applications can specify up to 10 “app-bound” domains using a new Info.plist key `WKAppBoundDomains`. For more information see [App-Bound Domains](https://webkit.org/blog/10882/app-bound-domains/).
|
||||||
|
|
||||||
|
| Type | Required | Platform |
|
||||||
|
| ------- | -------- | -------- |
|
||||||
|
| boolean | No | iOS |
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
<WebView limitsNavigationsToAppBoundDomains={true} />
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### `autoManageStatusBarEnabled`
|
### `autoManageStatusBarEnabled`
|
||||||
|
|
||||||
If set to `true`, the status bar will be automatically hidden/shown by WebView, specifically when full screen video is being watched. If `false`, WebView will not manage the status bar at all. The default value is `true`.
|
If set to `true`, the status bar will be automatically hidden/shown by WebView, specifically when full screen video is being watched. If `false`, WebView will not manage the status bar at all. The default value is `true`.
|
||||||
|
@ -332,6 +332,7 @@ export interface IOSNativeWebViewProps extends CommonNativeWebViewProps {
|
|||||||
injectedJavaScriptForMainFrameOnly?: boolean;
|
injectedJavaScriptForMainFrameOnly?: boolean;
|
||||||
injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
|
injectedJavaScriptBeforeContentLoadedForMainFrameOnly?: boolean;
|
||||||
onFileDownload?: (event: FileDownloadEvent) => void;
|
onFileDownload?: (event: FileDownloadEvent) => void;
|
||||||
|
limitsNavigationsToAppBoundDomains?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MacOSNativeWebViewProps extends CommonNativeWebViewProps {
|
export interface MacOSNativeWebViewProps extends CommonNativeWebViewProps {
|
||||||
@ -614,6 +615,17 @@ export interface IOSWebViewProps extends WebViewSharedProps {
|
|||||||
* If not provided, the default is to let the webview try to render the file.
|
* If not provided, the default is to let the webview try to render the file.
|
||||||
*/
|
*/
|
||||||
onFileDownload?: (event: FileDownloadEvent) => void;
|
onFileDownload?: (event: FileDownloadEvent) => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Boolean value which, when set to `true`, indicates to WebKit that a WKWebView
|
||||||
|
* will only navigate to app-bound domains. Once set, any attempt to navigate away
|
||||||
|
* from an app-bound domain will fail with the error “App-bound domain failure.”
|
||||||
|
*
|
||||||
|
* Applications can specify up to 10 “app-bound” domains using a new
|
||||||
|
* Info.plist key `WKAppBoundDomains`.
|
||||||
|
* @platform ios
|
||||||
|
*/
|
||||||
|
limitsNavigationsToAppBoundDomains?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MacOSWebViewProps extends WebViewSharedProps {
|
export interface MacOSWebViewProps extends WebViewSharedProps {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user