I want to reward some in-app rewards to users for referring a friend and thinking of using branch.io.
I have understood that you can reward users a branch reward based on rule set on branch.io dashboard. I have also understood that the client (user) can call branch.redeemRewards()
to redeem the branch rewards.
I am trying to find a way to award some in-app rewards to the users though, and for doing so I need to inform my node server about these.
1. Is there a branch node sdk?
Branch doesn't have a node SDK, but they do have HTTP APIs to perform all the operations facilitated in native SDK: https://docs.branch.io/pages/apps/api/.
3. How can the server check and redeem the branch reward of each user and award them an in-app reward?
You can check and redeem the Branch rewards using the HTTP API.
For example :
To check the credits:
curl -XGET 'https://api.branch.io/v1/credits?branch_key=key_live_kaFuWw8WvY7yn1d9yYiP8gokwqjV0Swt&identity=steve'
To redeem credits
curl -XPOST https://api.branch.io/v1/redeem \
-d '{
"branch_key": "key_live_kaFuWw8WvY7yn1d9yYiP8gokwqjV0Swt",
"branch_secret": "secret_live_RrrsLqpzVcoVWf5t4ncQVpzlg2pRpGH9",
"identity": "steve",
"amount": "5",
"bucket": "default"
}'
The best practice in referral programs is to check the balance and redeem credits on client side (on mobile app).
2. How should this flow work?
There are two actors in the referral program: Referrer user and referred user. Before going through implementation, do go through online docs to setup referral rules on Dashboard: https://docs.branch.io/pages/viral/referrals/#give-reward
For referrer User within the app (using mobile SDK):
Set the user identity after initSession for example in iOS:
[[Branch getInstance] setIdentity:@"your_user_id"]; https://docs.branch.io/pages/apps/ios/#track-users
Share a link to the friend (referred user). https://docs.branch.io/pages/web/integrate/#share-deep-link
When the referred User deep links back inside the app after installation: