WIP FCM push messaging.

This commit is contained in:
Patrick Fic
2020-05-01 09:21:30 -07:00
parent c98e0b33fd
commit a9a8c3b6aa
10 changed files with 1327 additions and 37 deletions

View 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);
};