user6138777
user6138777

Reputation:

Android deep linking not redirecting to play store

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

Answers (3)

Alex Bauer
Alex Bauer

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:

  1. If your app is installed, the user will have the option of opening it (to send them there directly without showing a chooser, you need to Request App Links Verification).
  2. If your all is NOT installed, the user will be taken to 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...

  1. A custom URI scheme for situations where App Links don't work.
  2. Chrome Intents for Chrome.
  3. Deferred deep linking to make sure your users are still sent to the correct place in your app after downloading it.

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

v4_adi
v4_adi

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

Vishal Vaishnav
Vishal Vaishnav

Reputation: 3422

For redirecting on PlayStore use below line;

  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("use your playstore app Link")));

Upvotes: -2

Related Questions