Webview does not deeplink to open Custom URL Scheme on iOS
See original GitHub issueBug description:
On iOS, the following code does not redirect to open Custom URL Scheme.
However, if I change the Custom URL MyApp://
to https://
, it can open the link just fine.
<WebView
source={{ html:
`
<html>
<body>
<script type='text/javascript'>
window.location.href='MyApp://'
</script>
</body>
</html>
`
}}
/>
Expected behavior: WebView can open Custom URL (or open MyApp in other word)
Environment:
- OS: iOS
- OS version: 14.5.1
- react-native version: 0.62.2
- react-native-webview version: 11.2.3
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:9
Top Results From Across the Web
ios - WKWebView not opening custom URL scheme (js ...
This solution will work without adding custom URL Schemes to your apps plist file via LSApplicationQueriesSchemes . (Which is necessary since iOS 10...
Read more >Custom URL schemes in a WKWebView
This article is about handling custom URL schemes inside a WKWebView, and I'll give you a couple of examples that allow you to...
Read more >Deep Linking Using Custom URL Scheme Example in Swift
Source code is at: http://swiftdeveloperblog.com/deep-linking-using- custom - url - scheme /
Read more >iOS Custom URI Handlers / Deeplinks / Custom Schemes
Go to the URL Handlers section. In URL schemes, click Refresh, and on the left you'll find a list of all custom schemes...
Read more >Allowing apps and websites to link to your content
If the user has not installed your app, the system opens the URL in Safari, allowing your website to ... open(_:options:completionHandler:) in iOS...
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
I later find out that we need to specify the Custom URL in Info.plist for the key LSApplicationQueriesSchemes in order to make this works on iOS.
Just want to share here in case it might be useful for others.
same problem
My info.plist:
EDIT
I got around this problem as follows:
In my backend, instead of redirecting to ‘com.myapp://route/success’, I redirect to any HTTP route, for example: ‘https://www.myapp.com/route/success’.
So the onShouldStartLoadWithRequest function can intercept and do what I need to do.
Currently Deep Link does not work, as the onShouldStartLoadWithRequest function does not receive the URL.
Code snippet on the backend:
Code snippet in the App: