【发布时间】:2019-11-25 14:00:35
【问题描述】:
根据 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。
如何按照文档中的说明发送具有高优先级的消息?
【问题讨论】:
-
您是否尝试过在配置中设置优先级? godoc.org/firebase.google.com/go/messaging#AndroidConfig
-
谢谢加文,我会检查一下,需要知道这两个字段之间的区别。 android config 的优先级和 AndroidNotification 的优先级
-
使用客户端,好像只能发送
Message。Message结构有一个AndroidConfig字段。我认为这就是您设置优先级的方式。
标签: android firebase go firebase-cloud-messaging firebase-admin