Created
May 16, 2023 16:36
-
-
Save Zonalds/dc01ebe9b57f0fe9961f0d21fd0db607 to your computer and use it in GitHub Desktop.
Shows how to send Push notification using firebase.admin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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