Tengo problemas para ejecutar una función en la nube que envía una notificación personalizada a cada usuario. Por alguna razón, la notificación no sale en absoluto. No sé si es porque la promise no se está manejando adecuadamente. El siguiente es el código:
exports.scheduledMonMorngRingValueNotification = functions.pubsub.schedule('00 20 * * MON').timeZone('Asia/Kolkata').onRun((context) => { var db = admin.firestore(); const promises = []; db.collection("collection_A").get().then(async snapshot => { await snapshot.forEach(async item => { await db.collection('collection_B').doc(item.id).get().then(bItem => { // ... Some data crunching payload = { token: token, fcm_options: { analytics_label: 'aLabel', }, notification: { title: title, body: body, image: img }, }; promises.push(admin.messaging().send(payload)); }).catch(reason => { console.log('Could not fetch bItm: ' + reason); }); }); }).catch(error => { console.log('Could not fetch: ' + error); }); return Promise.all(promises).then((result) => { console.log('Promise all passed: ' + result + ' Promises: ' + promises); }).catch((error) => { console.log('Promise all failed: ' + error); }); });