I hope that you’ve already read my article on sending Slack notifications with Firestore and cloud functions - if not, please check it out here
In our previous articles, we saw how to create a simple Todo application with Firebase’s Firestore and also to create cloud functions that will send a Slack notification when we create a todo or check a todo as complete. Here we’ll be using the same base and build a push notification architecture.
Code from previous article
With the above reference, we can see that the sendMessage
function is been called when the triggers are executed. Let’s create another function for pushing notification and call it as pushMessage
Now make your client subscribe to the notifications
topic of your Firebase app and they’ll receive notifications whenever these triggers are executed.
And if you need to send push notifications to specific users, get the client’s registration token and push to the corresponding token with sendToDevice
and pass the registration token as the parameter.
Putting everything together looks like
Now with above code, you’ll be sending both Slack as well as push notifications. Later if you think you want to send a message to anything like Twilio or Discord, we can also do that. Just the creativity and the use case defines them.
Also do checkout our other articles on Firebase here:
Subscribe to our newsletter
Get the latest updates from our team delivered directly to your inbox.
Related Posts
10 Gems in Ruby that you will love
Let's go back to basics with Ruby on Rails and see some of the Gems that we use everyday at skcript. #StartWithSkcript
#100DaysOfCommits
Our CTO, Swaathi, talks about our commitment to the #100DaysOfCommit challenge. Join us.
18 Python packages you should be using right now
Let us look at some python packages that will get you started on your machine learning path #StartWithSkcript