Ramcharan Reddy
Ramcharan Reddy

Reputation: 689

Redirects to app store if app is not installed

Scenario is user will get a link to his email. If user clicks on the link, If app is already installed, app should open and if app is not installed it should redirect to app store.

I've seen deeplinks implementation, but I believe it needs some more implementation in backend too. Can any one help on this?

Redirect to application if installed, otherwise to App Store

gone through this. Is there any better way?

added gif for one more scenario:

in the below gif, from email to app it navigates directly? how?

enter image description here

Upvotes: 21

Views: 33418

Answers (1)

Murilo Paixão
Murilo Paixão

Reputation: 646

I'm assuming the link you want to pass by email is an https link. If that's the case, for iOS to be able to redirect it to your app, you'll need to implement universal links. This implementation requires you to register the domain you want to respond to on your entitlements file and add an apple-app-site-association file to your backend. This way Apple can verify the domain you're trying to respond to is really yours.

As a result, when the app gets installed, it can be invoked by your domain links via deeplinking.

Now when there's no installed app able to respond to a specific https domain link, the system will simply open it on a web browser. Consequently, you cannot force iOS to open such links on AppStore directly. What you can do is to check whether the running device is iOS when your website gets accessed and ask the system to show your app on AppStore.

And to request iOS to launch AppStore from a website you can use itms-apps:

const iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);

if (iOS) {
  // Just replace `https://` with `itms://` on your app's AppStore link.
  window.location.href = "itms://itunes.apple.com/us/app/google-maps-transit-food/id585027354?mt=8";
}

// In this example I'm redirecting to Google Maps app page on AppStore.

Note: This is just a simple example used to demonstrate the concept. For a real application, you may want to use a device detection library for browsers, like mobile-detect.js

Upvotes: 24

Related Questions