Skip to content

Instantly share code, notes, and snippets.

@15mgm15
Created January 24, 2019 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 15mgm15/1efce386ec549e27b5d369b89b7162cb to your computer and use it in GitHub Desktop.
Save 15mgm15/1efce386ec549e27b5d369b89b7162cb to your computer and use it in GitHub Desktop.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.notifyNewMessage = functions.firestore
.document('/promotions')
.onCreate(async (docSnapshot) => {
const promotion = docSnapshot.data();
//const recipientId = promotion['recipientId'];
const title = promotion['title'];
const payload = {
notification: {
title: "Hay una nueva promocion!",
body: title,
},
// data: {
// USER_NAME: senderName,
// USER_ID: promotion['senderId']
// }
}
const response = await admin.messaging().send(payload);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment