android 如何在用户之间发送通知?
How to send notification from user to user in android?
所以我想将通知从一个设备推送到另一个设备,为此我使用了 firebase 云功能,当然 node.js 在搜索时我发现有一个新的从 firebase firestore 检索 id 的方法,但无论如何都没有人很好地解释它这里是 node.js index.js 我收到以下错误:
TypeError: Cannot read property 'pharmacien_id' of undefined
at exports.sendCommandes.functions.firestore.document.onWrite.event (/user_code/index.js:8:35)
at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
at next (native)
at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:82:36)
at /var/tmp/worker/worker.js:710:26
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
这里是 index.js:
'use-strict'
const functions = require('firebase-functions');
const admin=require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendCommandes=functions.firestore.document("Pharmaciens/{pharmacien_id}
/Commandes/{commande_id}").onWrite(event =>{
const pharmacien_id=event.params.pharmacien_id;
const commande_id=event.params.commande_id;
console.log("pharmacien_id: "+pharmacien_id+" |commande_id: "+commande_id);
});
解决方案:
使用 (change,context) 更改事件,使用 context.params.uid
event.params.uid
TypeError: Cannot read property 'pharmacien_id' of undefined
at exports.sendCommandes.functions.firestore.document.onWrite.event (/user_code/index.js:8:35)
at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:112:27)
at next (native)
at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:82:36)
at /var/tmp/worker/worker.js:710:26
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
这里是 index.js:
'use-strict'
const functions = require('firebase-functions');
const admin=require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendCommandes=functions.firestore.document("Pharmaciens/{pharmacien_id}
/Commandes/{commande_id}").onWrite(event =>{
const pharmacien_id=event.params.pharmacien_id;
const commande_id=event.params.commande_id;
console.log("pharmacien_id: "+pharmacien_id+" |commande_id: "+commande_id);
});
解决方案:
使用 (change,context) 更改事件,使用 context.params.uid