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 !

Image for post
Firebase Referrals or Invites

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 !

Register Activity

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

  • USER CODE (my_code)
  • POINTS (money)
  • UID (User ID)
Image for post

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.

Refer Activity

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 :)

Few Snapshot


1). Register

Image for post

2). Refer Code

Image for post
Image for post

Source Code —

Written by

Tech Lead and Founder at @XenonStudio. #Mobile #AI. Visit :-

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store