android - 在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 消息具有HIGH优先级,并且我的消息的优先级显示为UNKNOWN。
如文档中所述,我如何发送具有高优先级的消息?
解决方案
从文档中notification_priority
:
设置此通知的相对优先级。优先级表示该通知应消耗多少用户的注意力。在某些情况下,低优先级的通知可能对用户隐藏,而用户可能会因更高优先级的通知而被打断。设置相同优先级的效果在不同平台上可能略有不同。请注意,此优先级与 AndroidMessagePriority 不同。此优先级在消息传递后由客户端处理,而 AndroidMessagePriority 是一个 FCM 概念,用于控制何时传递消息。
该参数目前在 Go SDK 中不可用。随时在 GitHub 存储库中提交功能请求。
推荐阅读
- python - 获取每个不同列值的所有唯一值
- xamarin - 使用 Materialpickerrender 一次选择并取消按钮标题在 Xamarin 表单中显示顶部
- flutter - 集团不更新状态。谁能告诉我这段代码有什么问题。这是我第一次尝试使用 bloc 架构
- user-interface - Model 可以使用接口与 MVC 中的 View 通信吗?
- angular-ngrx-data - 为什么我的 ngrx 数据自定义 URL 不起作用?
- django - 什么时候应该缓存什么数据?
- julia - 在 Julia 中对多变量函数进行数值积分的问题 WRT 单个变量(使用 hcubature)
- reactjs - 如何反向运行 react-spring 动画?
- cassandra - 如何在 Kubernetes 环境中实现 spark-cassandra 连接器的“repartitionByCassandraReplica”?
- python - Python:Mac 中的 Python 版本