What is the proper way to create user invite codes using Branch?

这一生的挚爱 提交于 2019-12-06 11:34:40

问题


I've been combing through the Branch.io Android docs and haven't come up with how to create user invite codes. I've gotten the basic Branch referral system working ok, but I'd like to assign each user a custom invite code similar to what you see with Uber and Airbnb.

My current implementation looks like this:

    mSmsBranchUniversalObject = new BranchUniversalObject()
            .setCanonicalIdentifier("invite/sms")
            .setTitle(getString(R.string.simple_share_title))
            .setContentDescription(getString(R.string.default_share_desc))
            .addContentMetadata("userId", mUserId);

    mSmsLinkProperties = new LinkProperties()
            .setChannel("sms")
            .setFeature("sharing");

    mSmsBranchUniversalObject.generateShortUrl(getActivity(), mSmsLinkProperties, new Branch.BranchLinkCreateListener() {
        @Override
        public void onLinkCreate(String url, BranchError error) {
            if (error == null) {
                mSmsShareLink = url;
            }
        }
    });

@OnClick(R.id.iv_sms)
public void smsShare() {
    Branch.getInstance(getActivity()).userCompletedAction(BranchEvent.SHARE_STARTED);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:"));
    intent.putExtra("sms_body", getString(R.string.share_sms, mSmsShareLink));
    startActivity(intent);
}

The following implementation gets me a link that looks something like this:

https://mydomain.app.link/A1BCdEf2gH

But I'd like to share something like: ADAM98 (see screenshot above), and have the user enter it at checkout etc.

Now creating an invite code manually for each user isn't much work, I could take the 1st four characters of the user's username and append some random characters to it. But then what do I do with it? I assumed that I would simply need to pass this code to .setAlias(mUserInviteCode) on mSmsLinkProperties.

Am I on the right track here? What is the proper flow to implement this? How do you handle this invite code once received on the install?


回答1:


Alex from Branch.io here.

We actually used to offer a referral code feature exactly as you've described, but deprecated it a while back in favor of a referral link system. The reason why is actually quite interesting: our partner apps found codes unnecessary and a lot of extra work. The way Branch handles referrals is fundamentally different and far more user-friendly, so you actually don't need to make the user enter a code at all.

Traditional app referral process

  1. Inviting User gets a code
  2. Inviting User gives a code to a friend (Invited User) and says 'go download this app and enter my code!'
  3. Invited User hopefully downloads the app, hopefully finds out how to enter a code, hopefully enters the code correctly
  4. Inviting User gets a reward

As you can see, plenty of places where that process can go wrong.

Branch referral process

  1. Inviting User gets a link
  2. Inviting User sends the link to a friend (Invited User)
  3. Invited User clicks the link, is sent directly to the Play Store, downloads the app, and automatically triggers the referral redemption logic without any manual work
  4. Inviting User gets a reward

This works because Branch tracks the user who originally created the link, and can report back on that when the new user successfully downloads/purchases/whatever else the first time after opening the link. It is a much simpler and more seamless process, and the Branch referral infrastructure is so reliable that it 'just works'.

Here is the documentation page for setting this up: https://dev.branch.io/features/referral-programs/



来源:https://stackoverflow.com/questions/42648707/what-is-the-proper-way-to-create-user-invite-codes-using-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!