Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Deep linking: Use the same link for the app and the play store

I have a website which enables the user to make a search query. The query might take some time to complete (minutes to days), and I would like to enable the user to download an Android app and receive the answer there, by sending an email with a link to the user.

I would like this mechanism to work whether the user has the app installed or not; in other words:

  • If the user has the app it should be opened with deep link that contains an identifier argument.
  • If the user does not have it it should open the play store on the app's page (e.g. https://play.google.com/store/apps/details?id=com.bar.foo&referrer=BlahBlah), let the user install it, and open the app with the identifier argument.

enter image description here

Is there a way to form a link that opens an Android application with an argument, that would work regardless if the app is installed or not?

like image 970
Adam Matan Avatar asked Feb 26 '15 13:02

Adam Matan


People also ask

What is the difference between deep links and app links?

When a user click an URL, it might open a dialog which asks the user to select one of multiple apps handling the given URL. On the other hand, An Android App Link is a deep link based on your website URL that has been verified to belong to your website. When user clicks that URL, it opens your app.

Can you deep link to another app?

Passing search data via deep linkingDevelopers will need to submit their app and deep linking apps on both iOS and Android to be indexed by Google. Alternatively, developers can use Google's short links to deep link mobile app users if the app is installed and direct others to the webpage.

How do I integrate a deep link app on Android?

Select Open deep link URL in a browser option. Click Next. For Android, select Open the deep link in your Android app. Then select your app from the dropdown, in this case the com.


3 Answers

This workaround might work:

  1. At the server side, create a redirect rule to google play. For example, https://www.foo.com/bar/BlahBlah will redirect to https://play.google.com/store/apps/details?id=com.bar.foo&referrer=BlahBlah.

  2. At the app, register the server side link as a deep link:

<data android:scheme="https"
          android:host="www.foo.com"
          android:pathPrefix="/bar" />

Now, if the app is installed, the URL will be caught and the path can be parsed to extract the BlahBlah part. If the app isn't installed pressing the link will redirect the user to the Play store with the referring URL.

enter image description here

Notes:

  • /bar/BlahBlah was converted to &referrer=BlahBlah, because the play store receives a URL argument and the deep link mechanism works with URL paths (as far a I can tell)
like image 68
Adam Matan Avatar answered Oct 18 '22 21:10

Adam Matan


You can try using this scheme(to be sent to the user):

intent://details?id=X&url=Y&referrer=Z#Intent;scheme=market;action=android.intent.action.VIEW;package=com.android.vending;end";

X: Package name of the App

Y: Deep link scheme which should be defined in the App's manifest. (Please refer this) Here, they have used this URL as an example: "http://www.example.com/gizmos" , therefore Y should be replaced by this URL.

Z: Can be any data which you want to pass to the App via Google Play. Please take note that any data which you pass should not be '&' separated because the original parameters are itself '&' separated.

From what I experimented, this URL is understood by the browser and it redirects you to the App based on the package name and the deep-link scheme. Else it takes you to the Google Play.

PS: The Google Play makes a broadcast to the app. So make sure you receive the broadcast in a receiver.

like image 27
Shivam Dixit Avatar answered Oct 18 '22 22:10

Shivam Dixit


This question is pretty old but also very popular, so it's definitely worth knowing that now this use case is officially supported by Firebase, precisely Firebase Dynamic Links.

It supports just opening app and deferred deep linking, which means that after installing app, when app is starting, you can retrieve data (link) that was used to install the app.

It's built on top of App Linking, so you still need the same intent-filter as before.

In short, you need to add implementation 'com.google.firebase:firebase-dynamic-links:VERSION' and retrieve link from instance of FirebaseDynamicLinks class.

Of course you need to change links on website with those generated in Firebase console, but the good news is that these links are "dynamic" (as the name implies) so they work on all systems.

For all detailed info and set up with that use case up go here: https://firebase.google.com/docs/dynamic-links/use-cases/web-to-app

like image 35
michalbrz Avatar answered Oct 18 '22 20:10

michalbrz