Search code examples
androiddeep-linkingwhatsapp

Deep link shared from my app to WhatsApp causes my app to be ontop of the opening app (WhatsApp)


I am using Branch.IO for deep linking into my app specific place.

I have a chat inside my app that works fine with the deep link.

The issue is that when I copy the link to Whatsapp and it opens the app, when closing my app using the home button and going back to whatsapp it goes back to my app.

This behaviour is unique to WhatsApp as I have tested Telegram and the issue does not occur there.

Here is my branch callback on my receiving activity -

private void initBranch() {
        Branch.getInstance().initSession((referringParams, error) -> {
            if (error == null && referringParams != null) {
                try {
                    String verteItemID = referringParams.getString(VerteItemID);
                    Intent intent = new Intent(this, ProductPageActivity.class);
                    intent.putExtra(VERTE_ITEM_ID, verteItemID);
                    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    startActivity(intent);

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, getIntent().getData(), this);
    }

Any ideas why this behaviour is unique to WhatsApp?


Solution

  • Solved - I added SINGLE_TOP flag to my activity (that is being opened) in the manifest