6

I am doing a fitness app in which I have to notify the user at a specific time from the date I have stored in firebase.

For example: I am saving a today's timestamp in firebase DB say "start_at":"timestamp", now I have to send a notification after 1 week from the date(timestamp) I stored.

It is similar to cron feature. I don't know exactly how to achieve it in firebase.

Is Anyone there to help me?

Hira
  • 293
  • 4
  • 19
  • I have no experience with this, but I can guide you I think. What would I look at is functions api and notifications api. You should be able to setup a trigger in functions to create a notification and time it. I know it is possible to set when to send notification from dashboard, so it has to be part of the api. Than you just setup this flow in the cloud function. You need payed acc to send notifications from cloud functions I think. – parohy Dec 14 '17 at 13:25
  • Just grab pay as you go. I think this enables you to send notifications from cloud functions but it is free. And you do not pay for traffic in free quota. – parohy Dec 14 '17 at 13:26
  • Possible duplicate of [Schedule a push notification with Firebase Cloud Messaging](https://stackoverflow.com/questions/40357256/schedule-a-push-notification-with-firebase-cloud-messaging) – AL. Dec 17 '17 at 07:26

1 Answers1

6

Firebase, and Google Cloud Platform in general, has no feature that let’s you schedule a notification or a Cloud Function trigger programmatically.

You have to choices:

  • Write a Cloud Function that will be triggered from Google App Engine with a frequency (es. 1 hour). Here is the explanation on how to schedule the execution.
  • Setup your own server to send notifications through the API of FCM. If you use Node.js you can use node-cron.
alessionossa
  • 923
  • 2
  • 15
  • 41
  • @Chitra any feedback? – alessionossa Dec 16 '17 at 11:26
  • I have tried your first choice, but I don't know how to set it for two weeks and also for a different users at different time. On second choice, we don't want to setup server separately for this project. – Hira Dec 19 '17 at 05:21
  • Also, how to make the cloud functions to listen the changes happening for particular user. For example, "functions.database.ref('/Users/{id}').onWrite(event .. " this is my function to listen for notification, here how can I pass the dynamic user id ? and to change the payload(notification) content and badge value dynamically ?Thanks – Hira Dec 19 '17 at 05:27