首页 > 解决方案 > 当应用程序被杀死时,推送通知不显示消息正文。它只显示应用程序的默认图标

问题描述

当我的应用程序运行时,会收到通知以及标题消息和应用程序图标,如下所示 在此处输入图像描述

但是当我被杀死时,它不会显示消息正文,仅显示图标和标题,即像这样的应用程序名称

在此处输入图像描述

而我的 OnMessagerecieved 方法的代码是这样的

@Override
    public void onMessageReceived(RemoteMessage message) {
        String from = message.getFrom();
        Map data = message.getData();


        datarecieved = message;




        String orderIds= "";
        try {
            if(data.get("accountId")!=null)
                orderIds = data.get("accountId").toString();

        } catch (Exception e) {
            e.printStackTrace();
        }

        String userId=SharedPrefsUtils.getStringPreference(getApplicationContext(),"user_id");

        if(userId!=null&&userId.length()>0) {
            if (orderIds.equals("-101")) {
                generateNotificationForOrder(getApplicationContext(), data);
            } else if (!orderIds.equals("")) {
                generateNotification(getApplicationContext(), data);
            }
        }


    }

而我的通知 JSON 是这样的

{“to”:“fcm_token”,“data”:{“type”:“101 / 102 / 103”,“msg”:“CustomerId”,“id”:“0”,“accountId”:“-101” }, "content_available": 真 }

标签: push-notificationandroid-notifications

解决方案


推荐阅读