title: Firebase Error: Registration token(s) provided to sendToDevice() must be a non-empty string or a non-empty array
body: <p>i want to send users notification when they are being sent friend request using firebase cloud messaging, but when the request is sent it returns this error in firebase function log</p>
  
  <blockquote>
    <p>Error: Registration token(s) provided to sendToDevice() must be a non-empty string or a non-empty array.
        at FirebaseMessagingError.Error (native)
        at FirebaseMessagingError.FirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:39:28)</p>
  </blockquote>
  
  <p>this is the java-script code i am using</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>'use strict'
  
  const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp();
  
  exports.sendNotification = functions.database.ref('/Notifications/{user_id}/{notification_id}').onWrite((change, context) =&gt; {
   const user_id = context.params.user_id;
   const notification_id = context.params.notification_id;
  
   console.log('We Have A Notification for :', user_id);
  
   if (!change.after.val()){
    return console.log("A Notification Has Been Deleted From The Database: ", notification_id)
   }
  
   const deviceToken = admin.database().ref(`/Notifications/${user_id}/${notification_id}`).once('value');
  
   return deviceToken.then(result =&gt; {
  
    const token_id = result.val();
  
    const payload = {
     notification: {
      title: "Friend Request",
      body: "You just got a new friend request",
      icon: "default"
     }
    };
   
    return admin.messaging().sendToDevice(token_id, payload ).then(Response =&gt;{
   
     console.log('this is the notification')
    });
   
  
   });
  
  
  });</code></pre>
  </div>
  </div>
  </p>