Firebase 目前已推出Firebase 功能添加服务器端代码
Firebase 功能 https://firebase.google.com/docs/functions/
我想知道当数据库发生某些变化时是否可以通过这些函数调用 FCM 通知。
适用于云功能的 Firebase SDK https://github.com/firebase/firebase-functions包括Firebase 管理 SDK https://firebase.google.com/docs/admin/setup,您可以在这里找到我们制作的示例向新关注者发送 Firebase 云消息通知 https://github.com/firebase/functions-samples/tree/master/fcm-notifications
简单来说:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.foo = functions.database.ref('/bar').onWrite(event => {
const tokens = ...;
const payload = ...;
return admin.messaging().sendToDevice(tokens, payload);
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)