Created
February 28, 2023 17:48
-
-
Save tomcurran/9e558752e6ae2fa51aecd244f5b02eb7 to your computer and use it in GitHub Desktop.
Firebase Messaging Test
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
| const admin = require("firebase-admin"); | |
| const serviceAccount = require("./service-account.json"); | |
| const registrationToken = "REGISTRATION_TOKEN_1"; | |
| admin.initializeApp({ | |
| credential: admin.credential.cert(serviceAccount) | |
| }); | |
| const message = { | |
| notification: { | |
| title: 'Notification title test', | |
| body: 'Notification subtitle test' | |
| } | |
| }; | |
| admin.messaging().sendToDevice(registrationToken, message) | |
| .then((response) => { | |
| console.log('Successfully sent message:', response); | |
| }) | |
| .catch((error) => { | |
| console.log('Error sending message:', error); | |
| }); |
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
| { | |
| "dependencies": { | |
| "firebase-admin": "^10.0.2" | |
| } | |
| } |
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
| { | |
| "type": "service_account", | |
| "more": "properties" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment