Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS URL Type not working on React Native when using react-native-safari-view

I have set up a URL Type for my application in Xcode. For the purposes of the question I've removed actual bundle identifiers.

enter image description here

My project Bundle identifier is com.domain.foo.

I have a simple web page that merely redirects, with three different ways:

window.onload = function() {
  window.location.href="myschemereceiver://foo=bar";
  window.location="myschemereceiver://foo=bar";
  window.open("myschemereceiver", "_self");
}

However, when I load the URL inside of an embedded Safari View using this package, it doesn't redirect to my app.

When I load up the page in Safari, it does redirect to my application.

Edit:

Whenever I try to redirect to a URL Type that doesn't exist, Safari throws an error (which is expected). When changing it to the valid type, Safari doesn't do anything, just renders a white screen.

like image 359
Dan Avatar asked May 22 '26 15:05

Dan


1 Answers

Safari View Controller does not allow opening an app by clicking an URL inside it. To work around this problem you need to use WebView.

However your app will not launch if the WebView is called directly with the myschemereceiver://foo=bar (since typing the URL directly in safari address bar will not launch the app). When the user clicks inside the Safari View Controller, you need to launch a WebView with a website and the user should click another link or you need to use javascript from within that website to open your app from there.

More info on app and browser support for universal links can found here.

like image 87
Dani Akash Avatar answered May 24 '26 18:05

Dani Akash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!