android - Sending Arbitrary data with notification style Firebase cloud messaging -


i have short question. want send custom value cloud function listens onwrite events in firebase database. code 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 database structure looks this:

chats

-notifications

-some id

-username: fdsdf

-uid: 9043554

how can send uid device? way in code not work displayname... how supposed it

you can pass arbitrary key value pairs in notification message adding data key same level notification key in payload:

{"notification": {...}, "data" : {       "uid": 9043554     } } 

Comments

Popular posts from this blog

go - serving up pdfs using golang -

python - Best design pattern for collection of objects -

r - Using `bbmle:mle2` with vector parameters (already works using `optim`) -