Push notification depending on the date in the user base

Viewed 23

I have a Firebase database in which the user can write the date and time of the next workout. How to make the user receive a push notification the day before that he has a workout tomorrow?

2 Answers

The example of using Google Cloud Tasks that the other answer gave works (I'm actually using that exact pattern), but that may be over-complicated for your usecase.

Instead, just schedule a function to run on a one-a-day (or more or less frequent) schedule, check out this documentation. In this function, you can determine which users need reminders, and then send out bulk notification to those users.

You could also run this function a few times a day, allowing the user to select morning, afternoon, or evening notification if you want to allow that, only notifying users who are in that reminder slot.

If you need to customize the exact time the notifications are sent on a per-user basis (as opposed to all users getting the reminder at the same time), or there's too many users to process and send notifications in bulk in a single function invocation, then using the cloud tasks pattern might make sense.

Related