当前位置: > > > > 在 firebase admin go 客户端中设置 notification_priority
来源:stackoverflow
2024-05-01 22:12:37
0浏览
收藏
知识点掌握了,还需要不断练习才能熟练运用。下面给大家带来一个Golang开发实战,手把手教大家学习《在 firebase admin go 客户端中设置 notification_priority》,在实现功能的过程中也带大家重新温习相关知识点,温故而知新,回头看看说不定又有不一样的感悟!
问题内容
根据 firebase 文档,我们可以设置参数 notification_priority 来确定消息优先级。
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidnotification
{ "title": string, "body": string, "icon": string, "color": string, "sound": string, "tag": string, "click_action": string, "body_loc_key": string, "body_loc_args": [ string ], "title_loc_key": string, "title_loc_args": [ string ], "channel_id": string, "ticker": string, "sticky": boolean, "event_time": string, "local_only": boolean, "notification_priority": enum (notificationpriority),
我正在尝试使用 firebase admin go 客户端,但是当我看到消息结构时,我看不到该元素
结构体定义如下: https://godoc.org/firebase.google.com/go/messaging#androidnotification
type androidnotification struct { title string `json:"title,omitempty"` // if specified, overrides the title field of the notification type body string `json:"body,omitempty"` // if specified, overrides the body field of the notification type icon string `json:"icon,omitempty"` color string `json:"color,omitempty"` // notification color in #rrggbb format sound string `json:"sound,omitempty"` tag string `json:"tag,omitempty"` clickaction string `json:"click_action,omitempty"` bodylockey string `json:"body_loc_key,omitempty"` bodylocargs []string `json:"body_loc_args,omitempty"` titlelockey string `json:"title_loc_key,omitempty"` titlelocargs []string `json:"title_loc_args,omitempty"` channelid string `json:"channel_id,omitempty"` imageurl string `json:"image,omitempty"` }
firebase 文档和结构是否存在差异,或者我是否遗漏了某些内容? 问题是,如果设备处于睡眠状态,消息会发送到设备,但没有声音或屏幕显示。 (一加7 pro上出现,只是偶尔出现)
我使用以下命令检查了事件
1. Dial *#*#426#*#* to open the FCM Diagnostics page. 2. Tap the EVENTS button to show the event log. 3. Check whether the message was delivered to the device. There should be a log entry reading
看到 youtube 消息的优先级为高,而我的消息的优先级显示为未知。
如何按照文档中的描述发送高优先级消息?
解决方案
来自 notification_priority
的文档:
设置此通知的相对优先级。优先级指示该通知应消耗多少用户的注意力。在某些情况下,低优先级通知可能对用户隐藏,而用户可能会因高优先级通知而被打断。设置相同优先级的效果在不同平台上可能会略有不同。请注意,此优先级与 AndroidMessagePriority 不同。此优先级在消息传递后由客户端处理,而 AndroidMessagePriority 是一个 FCM 概念,用于控制消息何时传递。
Go SDK 目前暂不支持该参数。请随时在 GitHub 存储库中提出功能请求。
到这里,我们也就讲完了《在 firebase admin go 客户端中设置 notification_priority》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注公众号,带你了解更多关于的知识点!