How to make a indication system with firebase?

Hi there, everyone. My stepbrother told me having two accounts on the same computer could bring us problems so I am using his. Normally I would ask him directly but he is not available these days.
I will try my best to explain the situation.

I am creating an app that reward user with some points when the user recommend the app to a friend and this friend download the app and insert the friend referral code when signing up.

This referral code is saved in firebase realtime database in this format: users/userid/referralcode along with others informations like name, email, etc. At first I thought it would be easy. I would just have to create another field named users/userid/referralcodeofmyfriend. Example:
image

The problem is, if I save the data this way how can I update the points of the user that convinced his friend to download the app? If the refferal code was user id it would be easy (I just had to use the block store value user/ideoftheuser/points and add 100 more points there), but in this case the referral code must be different of the id.

So, what can I do to update the points of the users that recommend the app to their friends? Any ideas?
Thanks in advance and very sorry if my text is not clear.

It can be override if you do as below. Just my suggestion, may someother suggestion there could be . …

Whenever user is signed up, initially you will be saving his details under the tag users with initial point as zero

Meanwhile create another bucket with name Refcode, tag (generated code) value (user id)

So if the new user downloaded the app and input any users ref code , you can use web method

https://(project name.firebaseio.com/Refcode/(that generated code)/.json

So this will give two details

  1. If the web got text null mean, red code is invalid, else it will give you as
    Refcode:user id in a dictionary format.

Now you can take this user id and make into project bucket, get existing point, then add the reward and once again save.

Also you can add me user id of the one used the Refcode back to list. So under ever Refcode tag value, first I’d will be the owner of the code and the following will be The users who used the code.

Can you understand something with my English???

2 Likes

I am not sure if I understood, but not because of your english but because I am still a newbie.
But I think it makes sense. As soon as I can I will try it and come back here to say if it worked.

1 Like

Good… BTW, I meant like this…

Before using the refcode:point_down:
image

After using ref code :point_down:

image

1 Like

or you can use gsheet / baserow /airtable

I am trying to use only firebase in this project.

Anyways, I believe your suggestion will work perfectly. I can’t test it right now because we are making preparations for Christmas but I am 99% sure that it solves my problem. I am anxious to test it and come back here and mark your answer as solution :joy: :wink:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.