Home > Software design >  Schedule a notification at a specific time and date using firebase cloud messaging in NodeJs server
Schedule a notification at a specific time and date using firebase cloud messaging in NodeJs server

Time:10-17

I have successfully implemented Notification in my app using firebase cloud messaging and was able to send notification in my API in the node server using this admin.messaging().sendToDevice(registrationToken, message, notify_options)

My Question is there a way to schedule this at a specific time and date, for example on Dec 25 on christmas.

CodePudding user response:

Is there a way to schedule this at a specific time and date

Yes, you can use a scheduled Cloud Function. Since Cloud Functions for Firebase use the Node.js Admin SDK, it's just a matter of reusing your Nodes.js code.

You'll need to save the users registrationTokens in a storage that the Cloud Function can read: we usually use Firestore for that.

There is an example in the Cloud Function Sample Library.

  • Related