I am using the following piece of code for launching my app from safari. What I want is, when a user clicks on the link from safari, it will launch my app, and If the app is not installed in device, safari will redirect to the iTunes link of that particular app.
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's not set, you'll get an ugly "Cannot Open Page"
// dialogue prior to the App Store application launching
window.location = "custom-uri://";
Everything is working fine, except safari showing an error alert before redirecting to the iTunes link (if the app is not installed in device).
"Safari cannot open this page, because the address is invalid".
As it is a bad user experience, is there any way that I can suppress or avoid this popup before redirecting to the iTunes link.?