Skip to content

Instantly share code, notes, and snippets.

@Zonalds
Created May 16, 2023 16:36
Show Gist options
  • Save Zonalds/dc01ebe9b57f0fe9961f0d21fd0db607 to your computer and use it in GitHub Desktop.
Save Zonalds/dc01ebe9b57f0fe9961f0d21fd0db607 to your computer and use it in GitHub Desktop.
Shows how to send Push notification using firebase.admin
import admin from "firebase-admin";
// initialize the admin
admin.initializeApp({
credential: admin.credential.cert({
projectId: project_id,
clientEmail: client_email,
privateKey: private_key
})
});
//send the message
let message = {
notification: {
title: title,
body: text,
},
token: [] //aray of device token to send the push message to
};
const messageApp = await admin.messaging()
.send(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment