Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Deep Link for Mobile App

I want to create a promotional link for my app - which i can distribute via email. When the user clicks on the link from the email, a webpage does this:

  1. Determines which OS (iOS or Android)
  2. If app installed on device - opens the app
  3. Else - takes user to AppStore (or) PlayStore (or) a custom URL.

I tried using the AppLinks (applinks.org) - but I am unable to get it to work. How does the browser understand the "al:xx:xxx.." tags ? Does it only work for facebook/twitter?

<html>
    <head>
       <meta property="al:ios:url" content="applinks://docs" />
       <meta property="al:ios:app_store_id" content="12345" />
       <meta property="al:ios:app_name" content="App Links" />
       <meta property="al:android:url" content="applinks://docs" />
       <meta property="al:android:app_name" content="App Links" />
       <meta property="al:android:package" content="org.applinks" />
       <meta property="al:web:url" content="http://applinks.org/documentation" />
   </head>

I also tried some javascript from another post - but if the app is not installed the browser shows an error:

<script>
    window.onload = function() {
        window.location = 'http://www.launchMyApp';

        setTimeout("window.location = 'http://play.google.com/someApp';", 1000);
    }
</script>

Please help with this. Thanks.

like image 724
vepe Avatar asked Feb 23 '15 23:02

vepe


2 Answers

This is now possible in iOS 9. Apple announced Universal deep links this year in WWDC 2015. You may want to watch the video - Seamless Linking to Your App.

It can now:

  1. Check if app installed and open the content in iOS app
  2. Else fails gracefully and can open the content in safari.

One of the best feature of iOS 9 after Search API's.

like image 62
mojo_ Avatar answered Sep 23 '22 07:09

mojo_


al:xx:xx:xx

What they gave you is a URI (See This SO post for the differences between URIs, URNs, and URLs. When your app is installed it can register itself to respond to a certain URL-scheme. Here's an example Spotify URI that links to a song.

spotify:track:0FutrWIUM5Mg3434asiwkp

If you have Spotify installed on your device (desktop included), you can click this link and it should open the Spotify app automatically. The app responds because it has registered itself as a responder to that type of URL. The rest of the URI is used by the app in order to perform some specific action(s). In this case, Spotify recognizes the URI as a link to a song with a specific track identifier, and opens the appropriate screen.

Your app could register itself to respond to a specific URL-scheme, and if a user taps on that link with the app installed, it would open directly to your app. The downside is that if the app isn't installed, the OS won't understand the URL-scheme, and throw an error.

The solution I think you're looking for would be a simple HTTP link to a page (script) that's hosted on your site. You could pass in parameters just as you would a normal link

http://www.myapp.org/?user=123&source=email. 

Your page would employ some server-side Javascript that would attempt to open the URL-scheme that's specified by your app -- Similar to what you have posted above. If that fails, it would then redirect the user to the appropriate app store based on the browser information in the HTTP User-Agent header. You might need some other Javascript to suppress the alerts.

like image 42
Pat Butkiewicz Avatar answered Sep 22 '22 07:09

Pat Butkiewicz