I have a web app that I want to be able to open other apps for and have some deep links. The way I'm doing it now is very simple. I set a timer for 500ms in the future that goes to the app store and then immediately try to go to the deep link.
function attemptRedirect() {
const OS = getMobileOperatingSystem();
if (OS === 'IOS') {
setTimeout(() => window.location.href = content.ios_store_link, 500);
window.location.href = content.ios_app_link;
}
if (OS === 'Android'){
}
}
The issue I'm facing with this code is that if the deep link doesn't work, safari displays a giant error "Safari cannot open this page because the address is invalid" before moving over to the app store.
I can set the timer to run very quick so that the error is barely perceptible but if a user navigates backwards they'll still see it.
Is there a way to make sure the link works before trying the window.location
call?
For example one of my deep links is: myzone://open