适用于Android的FCM:应用程序在后台运行时弹出系统通知 [英] FCM for android: popup system notification when app is in background

查看:629
本文介绍了适用于Android的FCM:应用程序在后台运行时弹出系统通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在屏幕顶部显示弹出框以通知Firebase系统通知(当应用程序处于后台时)?为此,我使用setPriority(Notification.PRIORITY_MAX)onMessageReceived中显示来自onMessageReceived的通知.

Is it possible to show popup for firebase system notification (when app is in background) on the top of screen? I use setPriority(Notification.PRIORITY_MAX) for this to show notifications from onMessageReceived in foreground.

我同时使用notificationdata字段,所以我无权访问前台收到的通知.我尝试将priority设置为high并使用仅通知推送-没有帮助.

I use both notification and data fields, so I don't have access to received notification in foreground. I've tried setting priority to high and using notification-only pushes - nothing helps.

推荐答案

仅当使用data负载时,当应用程序处于后台时,才可能在onMessageReceived中处理消息.

It is only possible to handle the message in onMessageReceived when your app is in background when using a data only payload.

在有效负载中同时使用notificationdata时,预期的行为是,无论应用priority的值是多少,Android系统都会在应用程序处于后台时处理通知.

When using both notification and data in your payload, the expected behavior is that the Android System will handle the notification when the app is in background, regardless of what is the value of your priority.

请参阅处理Android消息上的官方文档详细信息.

See the official docs on Handling Android Messages for more details.

这篇关于适用于Android的FCM:应用程序在后台运行时弹出系统通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆