0

I have the following code creating the deep link -

public class BranchIOUtils {

    public static BranchUniversalObject createContentReference(Context context, MiniProductModel objectToPass) {
        return new BranchUniversalObject()
                // .setCanonicalIdentifier("content/12345")
                .setTitle("ProductPage")
                .setContentDescription(objectToPass.getProductParentFields().getShortDescription())
                .setContentImageUrl(objectToPass.getProductsIndividualField().getPictureList().get(0))
                .setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
                .setLocalIndexMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
                .setContentMetadata(new ContentMetadata()
                        .addCustomMetadata("source", "TwoVerte Android")
                        .addCustomMetadata("version", "1.0")
                        .addCustomMetadata("type", "ProductPage")
                        .addCustomMetadata("VIId", objectToPass.getProductsIndividualField().getVerteItemId()));
    }

    public static LinkProperties createLinkProperties() {
        return new LinkProperties()
                .setFeature("ProductPage")
                .setCampaign("ProductPage")
//                .setStage("new user")
                .addControlParameter("$desktop_url", "https://myverte.com/")
                .addControlParameter("$fallback_url", "https://myverte.com/");
//                .addControlParameter("custom_random", Long.toString(Calendar.getInstance().getTimeInMillis()));
    }

    public static void shareDeepLink (Context context, BranchUniversalObject branchUniversalObject, LinkProperties linkProperties, Branch.BranchLinkShareListener listener) {

        ShareSheetStyle shareSheetStyle = new ShareSheetStyle(context, "Check this product!", "This stuff is awesome: ")
//                .setCopyUrlStyle(ContextCompat.getDrawable(context, android.R.drawable.ic_menu_send), "Copy", "Added to clipboard")
//                .setMoreOptionStyle(ContextCompat.getDrawable(context, android.R.drawable.ic_menu_search), "Show more")
                .addPreferredSharingOption(SharingHelper.SHARE_WITH.FACEBOOK)
                .addPreferredSharingOption(SharingHelper.SHARE_WITH.EMAIL)
//                .addPreferredSharingOption(SharingHelper.SHARE_WITH.MESSAGE)
//                .addPreferredSharingOption(SharingHelper.SHARE_WITH.HANGOUT)
//                .addPreferredSharingOption(shareWith)
                .setAsFullWidthStyle(true)
                .setSharingTitle("Share With");

        branchUniversalObject.showShareSheet((Activity) context, linkProperties,  shareSheetStyle, listener);
    }

So my issue is the following -

I do get the sheet menu that I can select from many supporting apps to share my information. If I check anything rather my own app (which has a built in messaging system, similar to WhatsApp) the deep link works fine and the referringParams has a valid value which I can work with -

enter image description here

But if I share it via my app messaging system, I get nothing -

enter image description here

My guess is that it is something to do with the SHARE_WITH enum -

package io.branch.referral;

/**
 * Define the Applications for the sharing the link with.
 */
public class SharingHelper {
    /**
     * <p>
     * Defines the Application for sharing a deep link with.
     * </p>
     */
    public enum SHARE_WITH {
        FACEBOOK("com.facebook.katana"),
        FACEBOOK_MESSENGER("com.facebook.orca"),
        TWITTER("com.twitter.android"),
        MESSAGE(".mms"),
        EMAIL("com.google.android.email"),
        FLICKR("com.yahoo.mobile.client.android.flickr"),
        GOOGLE_DOC("com.google.android.apps.docs"),
        WHATS_APP("com.whatsapp"),
        PINTEREST("com.pinterest"),
        HANGOUT("com.google.android.talk"),
        INSTAGRAM("com.instagram.android"),
        WECHAT("jom.tencent.mm"),
        SNAPCHAT("com.snapchat.android"),
        GMAIL("com.google.android.gm");

        private String name = "";

        private SHARE_WITH(String key) {
            this.name = key;
        }

        public String getAppName() {
            return name;
        }

        @Override
        public String toString() {
            return name;
        }
    }
}

As you can see, I am limited to several packages of apps to choose from and I can't put my own app package name. So if I am correct - this is the problem.

edit -

even without the SHARE_WITH it does not work - the deep link stops working from inside my app but does work from outside of it.

How can I solve this issue and allow deep link to be sent using my own app package?

Alon Shlider
  • 1,187
  • 1
  • 16
  • 46

1 Answers1

0

You might now receive params if you are using link from live mode and your app is having key from test mode. Please make sure that following code is not present there:

Branch.enableDebugMode();

Also, make sure that you are not using test mode key:

<meta-data android:name="io.branch.sdk.TestMode" android:value="true" />

In order to validate your app setup, could you please try the following:

Test your Branch Integration by calling IntegrationValidator.validate in your MainActivity's onStart(). Check your ADB Logcat to make sure all the SDK Integration tests pass. Make sure to comment out or remove IntegrationValidator.validate in your production build.

IntegrationValidator.validate(MainActivity.this);

While tapping on the link you can set the App in debug mode and see if the data is getting updated in Branch Liveview. You can refer to this (https://docs.branch.io/apps/android/#enable-logging) for more details.

Make sure that every test passes, you can see this in the ADB console.

You can verify the setup with our troubleshooting documentation: https://docs.branch.io/apps/android/#troubleshoot-issues

In case above generic solution does not fix your issue, you can reach out to us at support@branch.io

Shubham Mishra
  • 1,303
  • 13
  • 24