Gal Gal - 21 days ago 4
iOS Question

Avoid an error when trying to redirect a custom protocol scheme (appname://location) if its not registered

I'm using a "Bounce" web page that is linked from a text message to open my app. The "Bounce" web page essentiall does this:

<script type="text/javascript">
window.location.href = "appname://location";

and works great if the appname:// protocol scheme is registered. But if it is not, an error message is displayed to the user:

Cannot Open Page

Safari cannot open the page because the address is invalid

Any ideas on how to attempt to do this redirect, but not show an error if its not working?


There's only a hacky javascript method to make it 'work', the invalid popup will still appear but will shortly disappear if the app is not installed, and take them to a different url

document.location = "appname://location";
    document.location = "";
}, 50);