react-native-webview: mailto: and tel: links do not work in webview
Bug description:
If the page opened in the webview has any mailto: or tel: links, pressing them causes the webview to return the generic android page and fire the error events.
I believe the error is: net::ERR_UNKNOWN_URL_SCHEME
(android) and unsupported URL
(iOS)
Happens on both iOS and Android
To Reproduce:
Load any page with mailto and/or tel links.
Expected behavior:
Other schemas should be working
Screenshots/Videos:
Environment:
- OS: Android and iOS
- OS version: 8.1, 10, 13.2.3
- react-native version: 0.61.5
- react-native-webview version: 7.6.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 31 (2 by maintainers)
Commits related to this issue
- fix(mailto): intercept clics on mailto: and tel: to prevent error mailto: and tel: links do not work in webview That is why we intercept them and prevent loading those requests. https://github.com/re... — committed to cozy/cozy-flagship-app by trollepierre 2 years ago
- fix(mailto): intercept clicks on mailto: and tel: to prevent error mailto: and tel: links do not work in webview That is why we intercept them and prevent loading those requests. https://github.com/r... — committed to cozy/cozy-flagship-app by trollepierre 2 years ago
- fix(mailto): intercept clicks on mailto: and tel: to prevent error mailto: and tel: links do not work in webview That is why we intercept them and prevent loading those requests. https://github.com/r... — committed to cozy/cozy-flagship-app by trollepierre 2 years ago
- fix(mailto): intercept clicks on mailto: and tel: to prevent error mailto: tel: maps: geo: sms: links do not work in webview That is why we intercept them and prevent loading those requests. https://... — committed to cozy/cozy-flagship-app by trollepierre 2 years ago
- fix(mailto): intercept clicks on mailto: and tel: to prevent error mailto: tel: maps: geo: sms: links do not work in webview That is why we intercept them and prevent loading those requests. https://... — committed to cozy/cozy-flagship-app by trollepierre 2 years ago
- fix(mailto): intercept clicks on mailto: and tel: to prevent error mailto: tel: maps: geo: sms: links do not work in webview That is why we intercept them and prevent loading those requests. https://... — committed to cozy/cozy-flagship-app by trollepierre 2 years ago
@Visakeswaran not really, I just handled the links case by case with the
onShouldStartLoadWithRequest
prop and something like this:Does this still work? We found that when we open an
intent://
link,onShouldStartLoadWithRequest
prop is not called anymore (An errorCan't open url: intent://xxx
is displayed instead)It used to work on 5.x.x đ˘
Even when I added âintent://*â to whitelist, it still cannot open url intent://xxxx. Is there anyone has solution for this issue?
replace
originWhitelist={[*]}
withoriginWhitelist={['http://*', 'https://*', 'intent://*']}
add
originWhitelist={['https://*', 'http://*', 'tel:*', 'mailto:*']}
works for me.Update:
We found that we need to add
originWhitelist={['http://*', 'https://*', 'intent://*']}
so thatintent://
link can be handled withonShouldStartLoadWithRequest
(Note that mailto/tel/geo/etc. would likely have the same problem)The commit with breaking changes: https://github.com/react-native-community/react-native-webview/commit/0442126
I fixed it by adding
and
Please note that this wonât work on the iOS simulator, but will on the physical device.
This still crashed webview for me.
But, luckily this commit released with 11.0.0 features a new option
setSupportMultipleWindows
, which when set totrue
opens links that open in new tabs/windows (such as<a target="_blank">
) will now prompt to open in the system browser, rather than re-using the current WebView.So, once enabled the flag(default set to true), make the link open in a new tab
Update: if changing
target
is not a viable option, I suggest adding some fallbacks when error is thrown