[iOS] WebView automatically opens url that don't match originWhitelist in external browser
See original GitHub issueBug description:
In iOS, WebView with custom originWhitelist
automatically opens custom scripts in Safari without any user interaction.
To Reproduce:
<WebView
source={{
uri: 'https://www.bbc.com',
}}
originWhitelist={['https://*bbc.com']}
/>
Expected behavior: WebView doesn’t open custom scripts in Safari without any user interaction.
Screenshots/Videos: On load, the webview opens a link that doesn’t fit the whitelist automatically https://imgur.com/a/Tvbua2b
Error in expo console:
Environment:
- OS: iOS
- OS version: 13.5
- react-native version: React Native 0.62.2 for Expo SDK38
- react-native-webview version: ^9.4.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
React-native-webview in expo ios automatically opens url that ...
It's working in android, but however in iOS with custom originWhitelist , react-native-webview automatically opens custom scripts in Safari ...
Read more >External links in WebView to exter… | Apple Developer Forums
Hi,. I have a WebView based app, I want any external links within the default website in the WebView to open in a...
Read more >React-Native-Webview In Expo iOS Automatically Opens Url ...
React-Native-Webview In Expo iOS Automatically Opens Url That Don't Match Originwhitelist. WebViews allow you to display web content inside a native app, ...
Read more >WebBrowser - Expo Documentation
Opens the url with Safari in a modal on iOS using SFSafariViewController , and Chrome in a new custom tab on Android. On...
Read more >WebView - React Native Archive
source. Loads static HTML or a URI (with optional headers) in the WebView. Note that static HTML will require setting originWhitelist to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes I did. So you can’t rely on the webview component to whitelist your domain since it’s not working properly. I need to manually filter urls using
onShouldStartLoadWithRequest
. WithisTopFrame
attribute, you can filter out requests that are from iframes. AddonShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
to</Webview>
component and remove theoriginWhitelist
attribute:Note:
passesWhitelist
function is taken fromreact-native-webview
source https://github.com/react-native-webview/react-native-webview/blob/master/src/WebViewShared.tsx#L20Thanks, @phuwin95. Basically, this is a workaround until the maintainer doesn’t decide to fix the native code, as exposed by you in here: https://github.com/react-native-webview/react-native-webview/pull/1513
I’ll work your way but I really think that a proper solution should be provided since Android and iOS behave differently. @Titozzz any insight on that?