title: firebase cloud functions for push notifications are not working
body: <p>in my flutter app, i have saved every devices token to a collection in firebase database and i wrote the code for firebase cloud functions so it sends a message(notification) for every user that subscribed to a topic and have their token is in the tokens collection but it doesnt send anything when i add something to the topic i subscribed them to, heres my cloud functions code using javascrpit in the index file:</p>
  
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  
  admin.initializeApp(functions.config().functions);
  
  var newData;
  
  exports.myTrigger = functions.firestore.document('messages/{messageId}').onCreate(async (snapshot, context) =&gt; {
      //
  
      if (snapshot.empty) {
          console.log('No Devices');
          return;
      }
  
      newData = snapshot.data();
  
      const deviceIdTokens = await admin
          .firestore()
          .collection('messages')
          .get();
  
      var tokens = [];
  
      for (var tokened of deviceIdTokens.docs) {
          tokens.push(tokened.data().token);
      }
      var payload = {
          notification: {
              title: 'Push Title',
              body: 'Push Body',
              sound: 'default',
          },
          data: {
              message: newData.message,
              click_action: 'FLUTTER_NOTIFICATION_CLICK',
          },
      };
  
      try {
          const response = await admin.messaging().sendToDevice(tokens, payload);
          console.log('Notification sent successfully');
      } catch (err) {
          console.log(err);
      }
  });
  
  </code></pre>
  
  <p>and heres my database structure
  <a href="https://i.stack.imgur.com/sO8aw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sO8aw.jpg" alt="enter image description here"></a></p>
  
  <p>and the tokens collection :
  <a href="https://i.stack.imgur.com/tsQqr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tsQqr.jpg" alt="enter image description here"></a></p>
  
  <p>what am i doing wrong?</p>