【发布时间】:2017-04-16 18:57:53
【问题描述】:
我在 'users' 数组中有用户 Uid 作为 ['uid1','uid2'] 现在我将在云功能中向这些用户发送通知?
exports.sendNotificationFromCr = functions.database.ref('/cr/{crUid}/notifications/{notificationid}/').onWrite(event => {
const uid = ['uid1','uid2']; // some how i get this.
// some work to send notifications
// to all tokens of uid1 and uid2.
}
这是数据库结构:
users/
uid1/
name:{name}
FCM-key/
token1:true
token2:true
uid2/
...
FCM-key/
token3:true
使用 ['uid1','uid2'] 我想向我的数据库中的所有 3 个令牌发送通知。该怎么做?
【问题讨论】:
-
作为起点,您可以使用Firebase Cloud Messaging Sample 中的一些this code。
-
bob,我没有使用 javaScript 的经验,所以我不明白这里发生了什么。我从例子中学到东西,但只有一个例子。我可以通过更改此代码获得“uid1”和“uid2”,但现在我不知道如何向这些用户的所有令牌发送通知。
-
如果你想使用 Cloud Functions,你肯定需要学习 JavaScript。
-
是的,但这会让我的项目迟到。我希望他们在云功能中有 Java 或任何其他语言支持:/
标签: javascript android firebase firebase-cloud-messaging google-cloud-functions