设备系统托盘中带有有效负载的FCM通知未传递给App [英] FCM Notification with payload in device's system tray not getting passed to App

查看:64
本文介绍了设备系统托盘中带有有效负载的FCM通知未传递给App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android应用正在后台运行.在Firebase控制台中使用高级"选项中的有效负载创建了一条通知消息.收到通知并显示在设备的系统托盘上后,单击通知仅返回到应用程序,并且没有按启动程序活动的目的传递额外的数据有效载荷.默认情况下,该通知不会按照文档中的说明打开应用启动器.为什么设备系统托盘中的通知正在启动活动",但有时却只是正常地单击应用程序图标时才转到应用程序?

Android app is running in the background state. Created a notification message in the Firebase Console with payload in the Advanced options. After receiving the notification and shown on the device's system tray, clicking on the notification just goes back to the app and the data payload was not delivered in the extras on the intent of the launcher activity. The notification does not open the app launcher by default as specified in the documentations. Why is it that the notification in the device's system tray is launching the Activity, but sometimes it just goes to the app as it was clicking on the app icon normally?

推荐答案

当应用程序在后台运行时,您将在启动程序活动中将所有数据作为捆绑包获取.要获取这些值,请确保覆盖启动器活动中的onNewIntent.就我而言,这是启动屏幕.

You will get all the data as a bundle in your launcher activity when your app is in background. To get those values, Make Sure to override onNewIntent in the launcher activity. In my case, it was the splash screen.

@Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        if (intent.getExtras() != null) {
            for (String key : intent.getExtras().keySet()) {
                Object value = intent.getExtras().get(key);
                Log.d("data ", "Key: " + key + " Value: " + value);
            }
        }
    }

这篇关于设备系统托盘中带有有效负载的FCM通知未传递给App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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