I have a short question. I want to send a custom value from a cloud function which listens for onWrite events in the Firebase Database. My Code for the Cloud function:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.pushNotification = functions.database.ref('/chats/notifications/{pushId}').onWrite( event => {
var values = event.data.val();
const payload = {
notification: {
title: values.username,
body: values.message,
sound: "default",
displayName: values.username,
UiD: values.recieverUiD
},
};
const options = {
priority: "high"
};
return admin.messaging().sendToTopic(values.recieverUiD, payload, options);});
And now the database structure looks like this:
chats
-notifications
-some ID
-username: fdsdf
-uid: 9043554
How can I send the UiD to my device? the way like in the code does not work with displayName... how am I supposed to do it