error que me arroja:
Error: Registration token(s) provided to sendToDevice() must be a
non-empty string or a non-empty array.
at FirebaseMessagingError.FirebaseError [as constructor]
(/srv/node_modules/firebase-admin/lib/utils/error.js:42:28)
at FirebaseMessagingError.PrefixedFirebaseError [as constructor]
(/srv/node_modules/firebase-admin/lib/utils/error.js:88:28)
at new FirebaseMessagingError (/srv/node_modules/firebase-
admin/lib/utils/error.js:253:16)
at Messaging.validateRegistrationTokensType
(/srv/node_modules/firebase-admin/lib/messaging/messaging.js:911:19)
at Messaging.sendToDevice (/srv/node_modules/firebase-
admin/lib/messaging/messaging.js:532:14)
at DeviceToken.then.result (/srv/index.js:29:28)
at
at process._tickDomainCallback
(internal/process/next_tick.js:229:7)
este mi codigo
'use strict'
const functions = require('firebase-functions');
const admin=require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification =functions.database.ref
('/Notificaticion/{receiver_user_id}/{notification_id}')
.onWrite((data, context)=>
{
const receiver_user_id=context.params.receiver_user_id
const notification_id=context.params.notification_id;
console.log('tenemos una notificcacion para enviar a:',receiver_user_id);
if(!data.after.val()){
console.log('Se ha eliminado',notification_id);
return null;
}
const
DeviceToken=admin.database()
.ref('/perfil/{receiver_user_id}/device_token').once('value');
return DeviceToken.then(result=>
{
const token_id = result.val();
const payload = {
notification:{
title:"Nueva orden",
body:'verife el pedido',
icon:"default"
}
};
return admin.messaging().sendToDevice(token_id,payload)
.then(response =>
{
console.log('this was a notification feature');
});
});
});
donde se origina el error
const DeviceToken=admin.database().ref('/perfil/{receiver_user_id}/device_token').once('value');