【问题标题】:Android screen lock and firebase topic messagingAndroid 屏幕锁定和 Firebase 主题消息传递
【发布时间】:2022-01-07 17:09:15
【问题描述】:

应用订阅了一个主题,当应用处于前台或后台时,大部分会收到通知。但是,如果我锁定模拟器,我不会收到通知。这是由于主题消息传递的性质而设计的吗?

...
FirebaseMessaging.getInstance().subscribeToTopic("topic")
...

【问题讨论】:

  • 如果需要更多背景信息或代码来帮助评估,请告诉我。

标签: android firebase firebase-cloud-messaging


【解决方案1】:

所以问题是从我们的服务器发送的通知同时具有 notificationdata 有效负载。当模拟器屏幕被锁定(背景状态)时,data 负载没有被处理。在我们的例子中,值的 notification 有效负载中没有任何内容,因此一旦从推送通知中删除通知块,我们的应用就会唤醒并由

处理所有内容
    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
       //do stuff with your message like show notification, etc
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 2022-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    相关资源
    最近更新 更多