Referrals Feature Using Firebase — Android Tutorial
Ever had a thought that making a Refer and Earn or Referral Feature in your android app without using any server or too much work. Well firebase can do that for you, Using Firebase AUTH, Firebase Database, Firebase Deep Link and other feature we will create Refer Feature in No time. Let Go Then !
Lets talk about our app first, Here I have created a feature where user Register Himself with friends Invite Code or Refer Code, that code will get updated in Firebase Database, Both will get A point or Whatever you want him to provide, Alright lets see the code to understand better !
Here we will create a activity which take Users Email, Name And Password and Parse then to ReferActivity (Below) , So for registration we will need two activity one for taking details and one for the refer code. The Below Code is of the ReferActivity where we get users details and then we put it into firebase Database. Below is the Firebase Database Table, we will create 4 Things
- REFER CODE
- USER CODE (my_code)
- POINTS (money)
- UID (User ID)
Here We created a Random String of 5 Digit and put it into the Firebase Database and users Refer Code, also whenever users data is correct we will provide the refer code user 10 points and referral user 10 points. If refer code is null, then the user will get 10 points.
Download This App To Check Refer Feature's Working
Now Once User Is Registered , We Will Show Him His Refer Code, And No. Of Points he has, And Also a Button to share his refer code. As we are using firebase database so the refer points will get updated within seconds.
Now Use this code in your Main Activity or Refer Activity where user will be taken after registering. Where user will able to see his points and all. This Code will update his points, you can also surprise your user by changing the Refer Code points from Firebase Database :)
2). Refer Code