0

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

KAT
  • 125
  • 3
  • Does this answer your question? [iOS9: Try to open app via scheme if possible, or redirect to app store otherwise](https://stackoverflow.com/questions/32689483/ios9-try-to-open-app-via-scheme-if-possible-or-redirect-to-app-store-otherwise) – Trevor Dixon Jan 26 '23 at 14:50
  • https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app seems like the best way to go if you control the app. – Trevor Dixon Jan 26 '23 at 14:52
  • @TrevorDixon sorry nope I don't control the app. If the app is installed then everything works dandy. The issue is that safari recognizes the deep link as invalid if it's not before directing to the app store. – KAT Jan 26 '23 at 15:17

0 Answers0