ajurcevic / cloud-function-messaging

Examples of a Cloud Function to perform Cloud Messaging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Firebase Cloud Function Example

👉 Introduction Cloud Functions: https://firebase.google.com/docs/functions

👉 Introduction Cloud Messaging: https://firebase.google.com/docs/cloud-messaging

TL;DR: The project uses Cloud Functions to perform Cloud Messaging with the help of Realtime Database. All Firebase.

This Cloud Function example monitors the Firebase Realtime Database for new records. The Cloud Function then triggers the Cloud Messaging process and sends the message to the Topic, any device subscribed to that Topic will receive the message.

When the message is successful, it will record the timestamp for that record back into the database.

Project is using the latest firebase-admin and function versions at the time of writing.

Realtime Database

What your database structure should look like:

realtime-database

Subsciber devices

iOS / Android / Web, et al.

Devices need to subscribe to the same name as the topic set on 'line 16' to receive messages.

$ const topic = "custom-topic-name";

Installation

Add Firebase Functions to your project

$ firebase init functions

Deploy to Firebase

Deploy the Cloud Function

firebase deploy --only functions

About

Examples of a Cloud Function to perform Cloud Messaging

License:GNU General Public License v3.0


Languages

Language:JavaScript 100.0%