title: How to increment badge count with firebase cloud functions
body: <p>Right now my payload only sends 1 badge count, the value of the badge count does not increment. It remains as 1, even if you get more than 1 notifications. </p>
  
  <p>How should the javascript be written? </p>
  
  <p>My current code:</p>
  
  <pre><code>const functions = require('firebase-functions');                   
  const admin = require('firebase-admin'); 
  admin.initializeApp(functions.config().firebase);
  exports.sendPushForHelp = 
  functions.database.ref('/help/school/{id}').onWrite(event =&gt; {
     const payLoad = {
       notification: {
           title: 'Someone',
           body: 'needs help',
           badge: '1',
           sound: 'Intruder.mp3'
       }
     };
     return admin.database().ref('fcmToken').once('value').then(allToken =&gt; {
         if (allToken.val()) {
          const token = Object.keys(allToken.val());
          return admin.messaging().sendToDevice(token, payLoad).then(response =&gt; {
  
              });
          };
      });
  });
  </code></pre>