NSURLErrorDomain Arbitrary scheme not working on ios webview (react-native-webview)

Viewed 17

This error is occurring using react-native-webview but I dont know if it relates to that library or ios webview itself and/or my configuration (Info.plist etc.)

I have a link with a custom scheme "swish://" that would normally open the Swish application. However on iOS I get NSURLErrorDomain, error code -1002 "unsupported URL"

Ive added the url to Info.plist under

<key>LSApplicationQueriesSchemes</key>
<array>
<string>swish</string>
</array>

Ive added originWhiteList={['swish://', 'https://']} to the WebView

Strange thing is onNavigationStateChange from the webview logs

LOG  {"canGoBack": false, "canGoForward": false, "loading": true, "navigationType": "other", "target": 1909, "title": "", "url": "about:blank"}
LOG  {"canGoBack": false, "canGoForward": false, "loading": false, "target": 1909, "title": "", "url": "about:blank"}
LOG  {"canGoBack": false, "canGoForward": false, "loading": false, "navigationType": "click", "target": 1909, "title": "", "url": "swish://asd?b=c"}

and then it fails with

Encountered an error loading page {"canGoBack": false, "canGoForward": false, "code": -1002, "description": "unsupported URL", "didFailProvisionalNavigation": true, "domain": "NSURLErrorDomain", "loading": false, "target": 1909, "title": "", "url": "about:blank"}

so it is complaining about 'about:blank' ... I have no idea how to get around this. Entering "swish://" into safari opens the application as expected.

the html is basically

<a href='swish://asd?b=c'>SWISHhHH</a> (ive tried with various changes to that link to test if something else is wrong)

Anyone have any clue what Im missing?

1 Answers

You can add UrlSchemes in Xcode from this link, this should resolve the issue

Related