i'm have this code in my index.js to trigger when i create a data to cloud firestore, other user get a notification. but it's not work
const functions = require('firebase-functions'); const admin = require('firebase-admin');
admin.initializeApp();
const db = admin.firestore();
const fcm = admin.messaging();
exports.sendNotification = functions.firestore
.document('donorRequests').
onCreate(async snapshot => {
const req = snapshot.data();
var user = db.collection('account/{uid}').get()
if((db.collection('accounts/{uid}/isVolunteer').get()===true)
&&(db.collection('account/{uid}/bloodType').get()===req.bloodType)
&&(db.collection('account/{uid}/rhesus').get()===req.rhesus)
&&(db.collection('account/latestDonor').get()-Date.now()>54)){
const payload = {
"notification":{
title: 'Hai Pahlawan!',
body: 'Seseorang butuh kamu, yuk kita bantu :)',
clickAction: 'FLUTTER_NOTIFICATION_CLICK'
}
};
return fcm.sendAll(payload);
}
});