Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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();
       }
}
like image 206
Amira Elsayed Ismail Avatar asked Feb 03 '16 10:02

Amira Elsayed Ismail


1 Answers

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.

like image 124
damian Avatar answered Oct 05 '22 04:10

damian