Android Deep linking: Use the same link for the app and the play store
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.
This workaround might work:
At the server side, create a redirect rule to google play. For example,
https://www.foo.com/bar/BlahBlah
will redirect tohttps://play.google.com/store/apps/details?id=com.bar.foo&referrer=BlahBlah
.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.
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)