使用 FCM,当应用程序在后台或未运行时,我可以在系统托盘中收到推送通知。当应用程序在前台时,我可以覆盖 onMessageReceived 并使用 NotificationCompat
创建自己的 heads-up 通知。
有没有办法在我的应用程序在后台或未运行时创建一个 heads-up 通知?
谢谢
编辑:供参考,这是我通过 curl 发送到 https://fcm.googleapis.com/fcm/send
的消息有效负载
{
"to":"push-token",
"content_available": true,
"priority": "high",
"notification": {
"title": "Test",
"body": "Mary sent you a message!",
"sound": "default"
},
"data": {
"message": "Mary sent you a Message!",
"notificationKey":"userID/notification_type",
"priority": "high",
"sound": "default"
}
}