英文:
Send a FCM by combinations of topic and device tokens
问题
我正在尝试处理用户可以打开/关闭接收来自多个场景的通知的用例。
我设想每个场景都是一个主题。我正在使用Go SDK,我看到Message结构体中有Token和Topic两个属性。那么这是否意味着我可以通过主题和设备令牌列表的组合来发送FCM通知呢?
英文:
I'm trying to handle the use case that the user can turn on/off to receive notification from many scenarios.
I imaged that every scenario is a topic. I'm using go sdk and i saw that the Message struct have both Token and Topic. So does it mean that i can send a FCM by a combinations of a topic and list of device tokens ?
答案1
得分: 1
据我所知,目前没有办法在单个请求中将令牌和主题组合起来发送消息到 FCM API。最接近的方法是进行批量请求,其中一个请求用于主题,一个或多个请求用于令牌。
如果要允许用户关闭通知的显示,请考虑发送数据消息(而不是自动显示的通知消息),然后在客户端应用程序代码中处理这些消息的显示或不显示。
英文:
As far as I know there is no way to combine tokens and topics in a single request to the FCM API to send a message. The closest you can get is making a batched request, with one request for the topic(s) and one or more for the tokens.
To allow the user to turn off display of notifications, consider sending data messages (rather than notification messages that are auto-displayed) and then handling the display or non-display of those message in your client-side application code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论