How to redirect to the app store from a deep link if the app is not installed?
Asked Answered
G

4

10

I'd like for users to be able to share a link (e.g. app.com/SKFLA - this is primarily because deep links on their own aren't clickable) via Facebook etc. When clicked, this redirects to a deep link app://SKFLA. If the app is installed, this opens the app - this is all working fine so far. But if the app isn't installed, I'd like to open the app store on the relevant page. Is this achievable? Thanks!

Guitarist answered 3/12, 2018 at 15:52 Comment(0)
O
6

You need UNIVERSAL LINKS

Please check

IOS https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html

Android

https://developer.android.com/training/app-links/

It might also require some extra server-side setup.

Orthography answered 13/12, 2018 at 15:54 Comment(0)
G
1

If someone is still stuck in this issue and needs easiest solution, you will love node-deeplink

1.) If app is installed: Calling an app through deep linking will always call componentDidMount of root component. So you can attach a listener there. Like:

Linking.getInitialURL()
      .then(url => {
        if (url) {
          this.handleOpenURL({ url });
        }
      })
      .catch(console.error);

    Linking.addEventListener('url', this.handleOpenURL);



handleOpenURL(event) {
    if (event) {
      console.log('event = ', event);
      const url = event.url;
      const route = url.replace(/.*?:\/\//g, '');
      console.log('route = ', route);
      if(route.match(/\/([^\/]+)\/?$/)) {
        const id = route.match(/\/([^\/]+)\/?$/)[1];
        const routeName = route.split('/')[0];

        if (routeName === 'privatealbum') {
          Actions.privateAlbum({ albumId: id });
        }
      }
    }
  }

2.) If app is not installed: Just set up a route in your server and node-deeplink package will handle the bridging between web browser to app store when a app is not installed in your mobile.

By this, both the cases will be handled without any struggle

Grapevine answered 7/1, 2020 at 8:26 Comment(0)
A
0

Not sure about native behavior. We used third-party service like https://branch.io/deepviews/. There is a bunch of similar services.

Amends answered 4/12, 2018 at 1:46 Comment(0)
B
0

The easiest way I've found is to define a universal link, and if the app can't be open (is not installed) redirect them via mod_rewrite to the app store.

Let's say you have an app where you want to join a group and your universal link is somethign like www.yourdomain.com/joingroup?name=whatever having this add a rule in your server for the users that reach that link from an iPhone or ipad that don't have the app installed redirect them user the app store.

# Enable mod_rewrite module
server.modules += ( "mod_rewrite" )

# Redirect iOS users from /joingroup to App Store URL
$HTTP["useragent"] =~ "iPhone|iPad|iPod" {
    $HTTP["host"] =~ "^(www\.)?mydomain\.com$" {
        url.redirect = ( "^/joingroup(.*)" => "https://apps.apple.com/theidoftheappstore" )
    }
}

Bigler answered 11/6 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.