Avoiding Safari Warning When Redirecting to iTunes Link

I use the following code snippet to run my application from safari. I want, when a user clicks on the safari link, he will launch my application, and if the application is not installed on the device, safari will redirect to the iTunes link of this particular application.

   setTimeout(function() {
  window.location = "http://itunes.com/apps/myappname";
}, 25);

// If "custom-uri://" is registered the app will launch immediately and your
// timer won't fire. If it not set, you'll get an ugly "Cannot Open Page"
// dialogue prior to the App Store application launching
window.location = "custom-uri://";

Everything works fine, except for a safari that displays an error warning before redirecting to the iTunes link (if the application is not installed on the device).

"Safari cannot open this page because the address is not valid."

As a bad user interface, is there any way I can suppress or avoid this popup before redirecting to the iTunes link.?

+4

Source: https://habr.com/ru/post/1542119/


All Articles