Notify Users, Part 2 — Firebase Cloud Functions

Arathi Shankri
Flutter Community
Published in
5 min readJul 4, 2020

--

Courtesy: https://firebase.google.com/docs/cloud-messaging

This article complements my other article on “Firebase Notifications”. To test firebase notifications, one can simply use the Firebase Cloud Messaging console on Firebase. But in actual you would notify users when there’s a new email or a new tweet or trigger a reminder or give away free tokens in gaming apps; all-in-all to engage users with your app, to lure them to open or use your app. To be able to achieve this, mostly notifications would be sent using cloud functions or server-side code.

USE CASE

How to write a cloud function to send firebase notifications. Such cloud functions can be set to listen to changes on your Firebase table or can be triggered using HTTP. In this article, I will share with you how to write a cloud function and execute it as an HTTP function.

IMPLEMENTATION

Below are the steps to set up, write, deploy, and test your cloud function.

Step 1: Setup Firebase Cloud Messaging API

  1. A good starting point is of course the firebase documentation.
  2. Make sure you have added your project on firebase. (step 1 in the above documentation)
  3. Install node.js.

> You would need node NVM (Node Version Manager) only…

--

--