Reputation: 887
I am developing a Flutter quiz app for learning purposes using Cloud Firestore. The app is working fine, but the problem is that same user can read and play quiz multiple number of times in a single day. I want to restrict users to play quizzes only once per day. My research is not helping me out, so I decided to seek help here. How can I impose restrictions on the number of times the quiz played by users per day? Any help will be appreciated a lot.
Upvotes: 0
Views: 205
Reputation: 138924
I want to restrict users to play the quiz only once per day.
The simplest solution I can think of is to create a new field in each User object called "readyToPlay". This field should have the initial value of "true". As soon as the user finishes the first game, change the value of the field to "false". Then simply restrict the possibility to play the game according to this field. So you have to check at the beginning of each game, against this newly added field.
To reset the value of this field to "true", every single day, I recommend you write a function in Cloud Functions for Firebase and call it once a day using Cloud Scheduler, as explained in my answer from the following post:
Upvotes: 1
Reputation: 158
if I interpreted your problem correctly then this will work for you...
Upvotes: 2