【问题标题】:FCM- doesnt get notification when app is swiped off from recent apps [duplicate]FCM-从最近的应用程序中刷出应用程序时没有收到通知[重复]
【发布时间】:2017-04-08 14:45:01
【问题描述】:

没有错误 FCM 在应用打开时工作正常,如果它被关闭或刷掉,则不会触发通知。

【问题讨论】:

    标签: android firebase firebase-cloud-messaging


    【解决方案1】:

    Firebase 通知的行为因接收应用的前台/后台状态而异。如果您希望前台应用接收通知消息或数据消息,则需要编写代码来处理 onMessageReceived 回调。

    如果您的应用处于后台或关闭状态,则通知中心会显示一条通知消息,并且该消息中的任何数据都会传递到由于用户点击通知而启动的 Intent。

    https://firebase.google.com/docs/cloud-messaging/android/receive

    【讨论】:

    • ' super.onMessageReceived(remoteMessage); Log.d(TAG, "发件人:" + remoteMessage.getFrom());字符串消息体 = ""; if (remoteMessage.getData().size() > 0) { Log.d(TAG, "消息数据负载:" + remoteMessage.getData()); messageBody = remoteMessage.getData().values().toArray()[0].toString(); } if (remoteMessage.getNotification() != null) { Log.d(TAG, "消息通知正文:" + remoteMessage.getNotification().getBody()); } sendNotification(messageBody);'这是我的 onMessageRecieved() 代码
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-24
    • 1970-01-01
    • 2017-07-30
    相关资源
    最近更新 更多