FCM for android:应用程序在后台时弹出系统通知

FCM for android: popup system notification when app is in background(FCM for android:应用程序在后台时弹出系统通知)
本文介绍了FCM for android:应用程序在后台时弹出系统通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在屏幕顶部显示 Firebase 系统通知的弹出窗口(当应用程序在后台时)?为此,我使用 setPriority(Notification.PRIORITY_MAX) 在前台显示来自 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.

推荐答案

只有当你的应用在后台使用dataonMessageReceived中的消息> 仅有效载荷.

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

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

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.

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)