• <bdo id='LlUN9'></bdo><ul id='LlUN9'></ul>

  • <small id='LlUN9'></small><noframes id='LlUN9'>

    <tfoot id='LlUN9'></tfoot>
    1. <legend id='LlUN9'><style id='LlUN9'><dir id='LlUN9'><q id='LlUN9'></q></dir></style></legend>

        <i id='LlUN9'><tr id='LlUN9'><dt id='LlUN9'><q id='LlUN9'><span id='LlUN9'><b id='LlUN9'><form id='LlUN9'><ins id='LlUN9'></ins><ul id='LlUN9'></ul><sub id='LlUN9'></sub></form><legend id='LlUN9'></legend><bdo id='LlUN9'><pre id='LlUN9'><center id='LlUN9'></center></pre></bdo></b><th id='LlUN9'></th></span></q></dt></tr></i><div id='LlUN9'><tfoot id='LlUN9'></tfoot><dl id='LlUN9'><fieldset id='LlUN9'></fieldset></dl></div>
      1. 通过 FCM onMessageReceived 方法从 RemoteMessage 获取值

        Get value from RemoteMessage from FCM onMessageReceived method(通过 FCM onMessageReceived 方法从 RemoteMessage 获取值)
          <tfoot id='0W9uB'></tfoot>
        1. <legend id='0W9uB'><style id='0W9uB'><dir id='0W9uB'><q id='0W9uB'></q></dir></style></legend>

            <tbody id='0W9uB'></tbody>
            <bdo id='0W9uB'></bdo><ul id='0W9uB'></ul>

            <small id='0W9uB'></small><noframes id='0W9uB'>

              <i id='0W9uB'><tr id='0W9uB'><dt id='0W9uB'><q id='0W9uB'><span id='0W9uB'><b id='0W9uB'><form id='0W9uB'><ins id='0W9uB'></ins><ul id='0W9uB'></ul><sub id='0W9uB'></sub></form><legend id='0W9uB'></legend><bdo id='0W9uB'><pre id='0W9uB'><center id='0W9uB'></center></pre></bdo></b><th id='0W9uB'></th></span></q></dt></tr></i><div id='0W9uB'><tfoot id='0W9uB'></tfoot><dl id='0W9uB'><fieldset id='0W9uB'></fieldset></dl></div>

                1. 本文介绍了通过 FCM onMessageReceived 方法从 RemoteMessage 获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已将 gcm 迁移到 fcm 以获取推送通知消息.但是我如何从收到的 RemoteMessage 中获取捆绑数据的 onMesssageReceived 方法.

                  I have migrate gcm to fcm for push notification message. but how I Get bundle data from RemoteMessage received onMesssageReceived method.

                  Old GCM give bundle data onMessageReceiced method but in FCM there is RemoteMessage data.
                  

                  所以请告诉我如何解析远程消息以获取通知的所有值.

                  So please tell me how I parse remotemessage for get all value of notification.

                  我的工资单

                  {
                  "collapse_key":"score_update",
                  "priority":"high",
                  "content_available":true,
                  "time_to_live":108,
                  "delay_while_idle":true,
                  "data": 
                  { 
                      "message": "Message for new task",
                      "time": "6/27/2016 5:24:28 PM"
                  },
                  "notification": {
                      "sound": "simpleSound.wav",
                      "badge": "6",
                      "title": "Test app",
                      "icon": "myicon",
                      "body": "hello 6 app",
                      "notification_id" : "1140",
                      "notification_type" : 1,
                      "notification_message" : "TEST MESSAGE",
                      "notification_title" : "APP"
                    },
                  "registration_ids": ["cRz9SJ-gGuo:APA91bFJPX7_d07AR7zY6m9khQro81GmSX-7iXPUaHqqcOT0xNTVsOZ4M1aPtoVloLNq71-aWrMCpIDmX4NhMeDIc08txi6Vc1mht56MItuVDdA4VWrnN2iDwCE8k69-V8eUVeK5ISer"
                  ]
                  }
                  

                  推荐答案

                  在 FCM 中你收到的是 RemoteMessage 而不是 Bundle.

                  In FCM you received RemoteMessage instead of Bundle.

                  以下是我在应用程序中使用的方式,其中数据是我的 RemoteMessage

                  Below is the way I used in my application where data is my RemoteMessage

                  Map<String, String> data = remoteMessage.getData()
                  int questionId = Integer.parseInt(data.get("questionId").toString());
                  String questionTitle = data.get("questionTitle").toString();
                  String userDisplayName = data.get("userDisplayName").toString();
                  String commentText = data.get("latestComment").toString();
                  

                  以下是我从服务器发送的通知数据

                  Below is my notification data which I am sending it from server

                  {
                    "registration_ids": "",
                    "data": {
                      "questionId": 1,
                      "userDisplayName": "Test",
                      "questionTitle": "Test",
                      "latestComment": "Test"
                    }
                  }
                  

                  因此,您必须根据您的回复解析每个字段.由于我已经调试了代码,您将在 RemoteMessage 中收到地图,并将这些字段转换为适当的数据类型,因为所有这些数据都以字符串形式出现.

                  So you have to parse each and every field as per your response. As I have debugged the code you will receive map in your RemoteMessage and cast those fields in appropriate data types as all those data comes as string.

                  这篇关于通过 FCM onMessageReceived 方法从 RemoteMessage 获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                2. <legend id='FbcHw'><style id='FbcHw'><dir id='FbcHw'><q id='FbcHw'></q></dir></style></legend>
                  <i id='FbcHw'><tr id='FbcHw'><dt id='FbcHw'><q id='FbcHw'><span id='FbcHw'><b id='FbcHw'><form id='FbcHw'><ins id='FbcHw'></ins><ul id='FbcHw'></ul><sub id='FbcHw'></sub></form><legend id='FbcHw'></legend><bdo id='FbcHw'><pre id='FbcHw'><center id='FbcHw'></center></pre></bdo></b><th id='FbcHw'></th></span></q></dt></tr></i><div id='FbcHw'><tfoot id='FbcHw'></tfoot><dl id='FbcHw'><fieldset id='FbcHw'></fieldset></dl></div>
                    <tbody id='FbcHw'></tbody>

                    <small id='FbcHw'></small><noframes id='FbcHw'>

                    • <tfoot id='FbcHw'></tfoot>

                          <bdo id='FbcHw'></bdo><ul id='FbcHw'></ul>