title: Firebase Cloud Function trigger Cloud Messenger
body: <p>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</p>
  <p>const functions = require('firebase-functions');
  const admin = require('firebase-admin');</p>
  <p>admin.initializeApp();</p>
  <pre><code>const db = admin.firestore();
  const fcm = admin.messaging();
  
  
  exports.sendNotification = functions.firestore
      .document('donorRequests').
      onCreate(async snapshot =&gt; {
          const req = snapshot.data();
          var user = db.collection('account/{uid}').get()
          if((db.collection('accounts/{uid}/isVolunteer').get()===true)
              &amp;&amp;(db.collection('account/{uid}/bloodType').get()===req.bloodType)
              &amp;&amp;(db.collection('account/{uid}/rhesus').get()===req.rhesus)
              &amp;&amp;(db.collection('account/latestDonor').get()-Date.now()&gt;54)){
              const payload = {
                  &quot;notification&quot;:{
                      title: 'Hai Pahlawan!',
                      body: 'Seseorang butuh kamu, yuk kita bantu :)',
                      clickAction: 'FLUTTER_NOTIFICATION_CLICK'
                  }
              };
              return fcm.sendAll(payload);
          }
      });
  </code></pre>