WIP FCM push messaging.
This commit is contained in:
41
server/firebase/firebase-handler.js
Normal file
41
server/firebase/firebase-handler.js
Normal file
@@ -0,0 +1,41 @@
|
||||
var admin = require("firebase-admin");
|
||||
|
||||
var serviceAccount = require("../../bodyshop-dev-firebase-adminsdk.json");
|
||||
|
||||
admin.initializeApp({
|
||||
credential: admin.credential.cert(serviceAccount),
|
||||
databaseURL: "https://bodyshop-dev-b1cb6.firebaseio.com",
|
||||
});
|
||||
//var defaultApp = admin.initializeApp(defaultAppConfig);
|
||||
|
||||
exports.sendNotification = (req, res) => {
|
||||
console.log("Firebase Send.");
|
||||
// const { ids } = req.body;
|
||||
// const url = cloudinary.utils.download_zip_url({ public_ids: ids });
|
||||
|
||||
var registrationToken =
|
||||
"dwsrcoeaIpwEmSzrVkE-_V:APA91bFurr0yCN-yXcaNrJvn8_f47I4vb4avxeS0NR5SCBPNADFB-gC79Hdmj7wqPccPmZCx0NzA_Dqi1lLYegpN-tFvANaK9I00oOSsFnOxv6KNZDLW0WguwFA0vQN8X50BaGuLTQqM";
|
||||
|
||||
var message = {
|
||||
data: {
|
||||
title: "850",
|
||||
body: "2:45",
|
||||
},
|
||||
token: registrationToken,
|
||||
};
|
||||
|
||||
// Send a message to the device corresponding to the provided
|
||||
// registration token.
|
||||
admin
|
||||
.messaging()
|
||||
.send(message)
|
||||
.then((response) => {
|
||||
// Response is a message ID string.
|
||||
console.log("Successfully sent message:", response);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("Error sending message:", error);
|
||||
});
|
||||
|
||||
res.sendStatus(200);
|
||||
};
|
||||
Reference in New Issue
Block a user