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?
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
Inviting User
gets a codeInviting User
gives a code to a friend (Invited User
) and says 'go download this app and enter my code!'Invited User
hopefully downloads the app, hopefully finds out how to enter a code, hopefully enters the code correctlyInviting User
gets a reward
As you can see, plenty of places where that process can go wrong.
Branch referral process
Inviting User
gets a linkInviting User
sends the link to a friend (Invited User
)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 workInviting 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