Android share deep link url using whatsapp and open my app when click deep link
Asked Answered
P

2

10

I am sharing some data using whatsapp, and I want to open a specific activity in my app when user press deep link from whatsapp

I have the following schema

myapp://openapp?type=banner&id=10

whatsapp share the link as a normal text not as url and also I can't open my app when user press it

can anyone help please ?

EDIT

this is my sharing method

public static void openWhatsApp(Context mContext) {

        PackageManager pm = mContext.getPackageManager();
        try {

            Intent whatsAppIntent = new Intent(Intent.ACTION_SEND);
            whatsAppIntent.setType("text/plain");

            String text = "myapp://openapp?type=banner&id=10";

            PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
            whatsAppIntent.setPackage("com.whatsapp");

            whatsAppIntent.putExtra(Intent.EXTRA_TEXT, text);
            mContext.startActivity(Intent.createChooser(whatsAppIntent, mContext.getString(R.string.share_with)));

       } catch (NameNotFoundException e) {
            Toast.makeText(mContext, "WhatsApp not Installed", Toast.LENGTH_SHORT).show();
       }
}
Polled answered 3/2, 2016 at 10:53 Comment(2)
You can also use the referral linking from these link technology.jana.com/2014/11/11/…Harslet
is it possible to redirect to play store if app not installed using same link?Histamine
G
8

I don't know if it's possible. It may be that WhatsApp only highlights links with certain protocols (i.e. http, https). In this case, you could go for a work-around if you are depending on this feature:

Let the user share a link to http://your-server.com/forward?type=banner&id=10

On your-server.com, you re-direct the user within the forward file (or via server configuration) to myapp://openapp?type=banner&id=10.

Of course this is not pretty, but browsers can handle these app-links. This will not be pretty, since the user will at first open a browser to process your http link, from which the user will be redirected.

Glennaglennie answered 3/2, 2016 at 11:9 Comment(2)
My friend [iOS Developer] told me that he is using "whatsapp://send?text=" and it works with him, but when I try it nothing happen.Polled
whatsapp://send?text=... will share the text with a WhatsApp user if I'm not mistaken, it is not supposed to highlight your custom-protocol URI within a WhatsApp chat.Glennaglennie
E
1

Exactly the same problem I'm facing atm. Using Android App-Links seems to be the correct solution. From the docs: https://developer.android.com/training/app-links/verify-site-associations.html#request-verify

The difference between deep links and app links:

  • A deep link is an intent filter that allows users to directly enter a specific activity in your Android app. (You tried to use this one, but Whatsapp doesn't recognize this as a link)
  • An Android App Link is a deep link based on your website URL that has been verified to belong to your website. (This is a normal http(s) link, it should be recognized as thus everywhere)
Eichmann answered 13/10, 2017 at 8:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.