【问题标题】:Send notification to status bar if app is in foreground如果应用程序在前台,则向状态栏发送通知
【发布时间】:2021-10-21 21:44:37
【问题描述】:

当我收到来自 Firebase Cloud Messaging 的推送通知并且我的应用处于后台时,我会在 android 的系统状态栏中收到此通知。 但是,如果我的应用在后台,我不会收到它,而是会引发 onMessageReceived

如果应用程序处于前台模式,是否可以显示此通知? 我知道我可以使用 NotifictionManager 并手动构建此通知,但如果应用程序在后台,Firebase SDK 应该有一种更简单的方法。喜欢

class FcmService: FirebaseMessagingService() {
    override fun onMessageReceived(message: RemoteMessage) {
        showNotificationInStatusbar(message)
    }

【问题讨论】:

    标签: android firebase push-notification firebase-cloud-messaging android-notifications


    【解决方案1】:

    我不认为 Firebase 正式支持这一点。请参阅这两个文档Receive messages in an Android app About FCM messages

    【讨论】:

    • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
    猜你喜欢
    • 2019-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多