Firebase Database Doubt

Hey Koders
I just created an app with phone login. I wish to link it with firebase database. The app suppose to give some points after playing games and add those points to the firebase database. I want to let every user start with 0 points and the will increase further. The problem is that app might get closed or maybe user will log out and I don’t want user’s point to get lost when he logs in back. In that case how can I prevent the app from overwriting the initially earned points in the database? You may get a clear idea from the image.

So in such case, when user star rating points after successful login then make clock to timer. And make it to send values to the firebase at particular interval

1 Like

That’s not the issue. Suppose I scored 500 points and these points got stored in firebase successfully. But unfortunately, I logged out. When I’ll log in back with my phone number, the code fragment will run again and it will reset the points to 0! That’s what the major issue is. I don’t want user’s points to get reset when he/she logs in back to the app.

You can create a signup procedure and when signup success call firebase store value 0 and then create a login procedure without storing again value 0. That way points won’t be lost

Don’t Store value zero here just make a label of zero points to show and after playing game store value like this :-

1 Like

Got it. I’ll try and will mark your response as solution if it helps. Thanks! :blush: