Slide 37
Slide 37 text
exports.sendNotification = functions.database.ref(`items/{itemId}`)
.onCreate((snapshot, context) => {
const data = snapshot.val();
const msg = admin.messaging.Message = {
topic: 'new-restaurant',
notification: {
title: 'New Restaurant in FireLechon’,
body: `We just added "${data.name}" to our collection. Enjoy!`
}
}
return admin.messaging().send(msg)
.then((resp) => {
return resp;
})
.catch(() => {})
})
#DevFest18