admin管理员组文章数量:1399950
I am using flutter, firebase cloud messaging, firebase cloud function and firestore. I am looking for a way to send push notifications to my app on data changed in firestore.
Problem 1: The app also allows users to customize their preference settings. For example, user can subscribe to each Item and any of its fields like price, expiration date, etc, thus they will only receive notifications from those subscribed fields from that Item only.
Problem 2: The app also allow users to customize their time-to-receive settings freely (just like how Slack builds). For example, user might want to receive notification only before midnight or after 10am, and another one only want to receive them at 7am-8am Monday (for example).
Current setup: I trigger cloud function everytime there's a change in any Items, and this will send notifications to fcm topics that follows this pattern "item_${itemId}_${changedField}". This works fine for Problem 1, but when it comes to problem 2, things get harder, since I can't create a new topic for each hour and day, because there will be too many topics for client to subscribe and unsubscribe for just a single Item and for cloud function to send notifications to.
Please any suggestions, thanks.
I am using flutter, firebase cloud messaging, firebase cloud function and firestore. I am looking for a way to send push notifications to my app on data changed in firestore.
Problem 1: The app also allows users to customize their preference settings. For example, user can subscribe to each Item and any of its fields like price, expiration date, etc, thus they will only receive notifications from those subscribed fields from that Item only.
Problem 2: The app also allow users to customize their time-to-receive settings freely (just like how Slack builds). For example, user might want to receive notification only before midnight or after 10am, and another one only want to receive them at 7am-8am Monday (for example).
Current setup: I trigger cloud function everytime there's a change in any Items, and this will send notifications to fcm topics that follows this pattern "item_${itemId}_${changedField}". This works fine for Problem 1, but when it comes to problem 2, things get harder, since I can't create a new topic for each hour and day, because there will be too many topics for client to subscribe and unsubscribe for just a single Item and for cloud function to send notifications to.
Please any suggestions, thanks.
Share Improve this question edited Mar 27 at 10:31 Ravindra S. Patil 15k5 gold badges19 silver badges51 bronze badges asked Mar 25 at 10:45 Triet DaoTriet Dao 374 bronze badges1 Answer
Reset to default 1In a scenario such as this (and honestly: many others) consider separating the delivery of the message from the display of the message. You can do this by using a message that only contains a data
node (so no notification
node). For such messages, it is always up to your code to handle the data.
So:
- Send the message as a
data
only message to the topic. - On the device in your application code, detect if the user has snoozed notifications.
- If not, display the notification right away.
- If they have snoozed notifications, schedule a local notification for the correct time.
本文标签: Develop a push notification preference system for flutter app using firebase toolsStack Overflow
版权声明:本文标题:Develop a push notification preference system for flutter app using firebase tools - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744202929a2595051.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论