我有一个任务要做云提醒使用Firebase。我的数据库里有一个提醒的时间戳。所以我需要在那个时候发出通知。
在Firebase测试控制台中,有一个在特定时间发送通知的选项,但我还没有在MessagingOptions中看到这个选项。
那么,使用Firebase函数实现云提醒的最佳方式是什么呢?此外:提醒的时间可以更改或移除。
发布于 2018-02-08 13:39:09
取决于项目的范围。
1. For scheduling a cron job I recommend you reading this [Firebase blog post](https://firebase.googleblog.com/2019/04/schedule-cloud-functions-firebase-cron.html)
2. For sending the push notification using FCM I recommend checking the [Functions samples on Github](https://github.com/firebase/functions-samples)
3. The best for starting with Functions is [this video](https://www.youtube.com/watch?v=EvV9Vk9iOCQ)
4. And for your database structure, please see example below
{
"user_alarms": {
"uid1": {
"pushkey1": {
"full_object": "goes here"
},
"pushkey2": {
"full_object": "goes here"
}
},
"uid2": {
"pushkey3": {
"full_object": "goes here"
},
"pushkey4": {
"full_object": "goes here"
}
}
},
"alarms": {
"pushkey1": {
"reduced_object": "mainly_the_time"
},
"pushkey4": {
"reduced_object": "mainly_the_time"
}
}
}
user_alarms节点包含每个用户警报,这样用户就可以看到已设置的所有警报。节点alarms是原始节点的去正规化,是要在每个cron作业上查询的节点。它包含一个更简单的对象,只包含执行对即将到来的警报的查询所需的内容,主要是触发时间。为了提高FCM推送后的性能,应该删除相应的对象。
发布于 2018-10-05 12:15:49
最简单的解决办法:
https://stackoverflow.com/questions/48686423
复制相似问题