Untitled
unknown
plain_text
2 years ago
682 B
9
Indexable
exports.sendNotificationOnNewDocument = functions.firestore
.document('teste/{documentId}')
.onCreate(async (snapshot, context) => {
const fcmToken = '...token aqui...';
if (fcmToken) {
const payload = {
data: {
title: 'New Document Added',
body: 'A new document was added to the "teste" collection.'
}
};
await admin.messaging().send({ token: fcmToken, data: payload.data });
console.log('Notification sent successfully');
} else {
console.error('FCM token is not provided');
}
return null;
});Editor is loading...