Reputation:
I have customized deep linking, it is working fine for users having the app. But for users not having the app, it doesn't redirect them to playstore.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="abc.in"
android:pathPrefix="/abc"
android:scheme="http" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
MY Code for generating deeplink
public void Share() {
firebaseAnalyticsUtil.fireEvent("shared_link");
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_SUBJECT,"Hey!");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Share Text - "+"http://abc.in/abc/"+ID);
startActivity(Intent.createChooser(sharingIntent,"Share using"));
}
Assist me to redirect user to playstore, if user does not have the app
Upvotes: 4
Views: 5583
Reputation: 13633
You are using App Links, which means these are regular http://
links. When your user clicks http://abc.in/abc
, one of two things will happen:
http://abc.in/abc
in their web browser.It's case 2 you're trying to handle, and the approach is simple: redirect your visitor to the Play Store using the page at http://abc.in/abc
. This can be done via Javascript or HTTP (a 307 redirect is the most common).
However, note that this alone is not enough for a complete deep linking solution. You also need to support...
I suggest looking into hosted deep link services like Branch.io (full disclosure: I'm on the Branch team) or Firebase Dynamic Links. They will make your life a lot easier.
Upvotes: 4
Reputation: 1533
For make it work for users who doesn' have your app, you can use Firebase dynamic link. You can also track parameter and analytics with Firebase dynamic link. It is free to use. Here is the link to its tutorial. It has easy to follow tutorial.
https://firebase.google.com/docs/dynamic-links/
If you find any trouble in implementing the dynamic link feel free to contact me.
Upvotes: 0
Reputation: 3422
For redirecting on PlayStore use below line;
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("use your playstore app Link")));
Upvotes: -2