<tfoot id='Ys9GE'></tfoot>

        <legend id='Ys9GE'><style id='Ys9GE'><dir id='Ys9GE'><q id='Ys9GE'></q></dir></style></legend>

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

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

      1. 如何从 Android 中的 FCM 数据消息中获取价值?

        How to get value from FCM data message in Android?(如何从 Android 中的 FCM 数据消息中获取价值?)

        <tfoot id='8Zrpu'></tfoot>
        • <bdo id='8Zrpu'></bdo><ul id='8Zrpu'></ul>
              <tbody id='8Zrpu'></tbody>

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

              <small id='8Zrpu'></small><noframes id='8Zrpu'>

                  <legend id='8Zrpu'><style id='8Zrpu'><dir id='8Zrpu'><q id='8Zrpu'></q></dir></style></legend>

                  本文介绍了如何从 Android 中的 FCM 数据消息中获取价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在我的应用中实现 FCM 通知.我已阅读 FCM 数据消息类型即使在应用程序处于后台时也会收到通知,因此我尝试在 onMessageRecieved 方法中实现该通知,但收到如下意外响应:

                  I'm trying to implement FCM notification in my app. I have read FCM data message type will receive notification even when app is in background so am trying to implementing that in onMessageRecieved method am getting unexpected response like this:

                  {title =2, message={"Status":"UNASSIGNED","CompanyName":"gd","LastModifiedDateTime":"2017-04-25 18:59:41","IsPartRequired":false,"ProblemCategory":"CONFIGURATION","IsGeneralClaim":false,"RegistrationID":1057,"IncidentCode":"INS/2017/04/25-0010","StatusID":0,"CreatedDateTime":"2017-04-25 18:59:41","IsInstallationCall":false}}
                  

                  不知道如何解析这个从标题和消息中获取单独的值让我发布我的 firebase 消息代码:

                  Don't know how to parse this get separate value from title and message let me post my firebase message code:

                  public class FireBaseMessage extends FirebaseMessagingService {
                      private static final String TAG = "MyFirebaseMsgService";
                  
                      @Override
                      public void onMessageReceived(RemoteMessage remoteMessage) {
                          super.onMessageReceived(remoteMessage);
                        Map<String,String> data = remoteMessage.getData();
                          Log.d(TAG, "From: " + data.toString());
                  // 
                  }
                  }
                  

                  在此日志消息中,我得到了这样的响应,如何从中获取价值是这样的尝试:

                  In this log message am getting response like that how to get value from that is try like:

                  int title=data.get("title"); 
                  

                  获取空指针,因为它的格式无效.在我的服务器端,我试图发布这样的 json 格式:

                  getting null pointer as this is not in valid format. In my server side i have am trying to post json format like this:

                  {
                     "to":"es_OToDkj00:APA91bFqxbVMAaXy5fPtDbNVAkIwyVrPCmfGci2otHZPvdRoXPv-oDdjgtLR92Nqe8w6f57nCVceLbc3_zBWsInG9g1Pfdp3LvsMKyuaiYps0L1y3tn0N0XbzGseEI6jyiqs1r-sT9lb",
                     "data":{
                        "message":{
                           "RegistrationID":1057,
                           "IncidentCode":"INS/2017/04/25-0010",
                           "CompanyName":"ABM INFOTECH",
                           "StatusID":5,
                           "Status":"ASSIGNED",
                           "CreatedDateTime":"2017-04-25T12:03:45",
                           "LastModifiedDateTime":"2017-04-25T18:59:41",
                           "ProblemCategory":"CONFIGURATION",
                           "IsPartRequired":false,
                           "IsInstallationCall":false,
                           "IsGeneralClaim":false
                        },
                        "title ":"1"
                     }
                  

                  不知道我在哪里犯了错误.谁能帮我?提前致谢!

                  Don't know where I'm making a mistake. Can anyone help me? Thanks in advance!

                  推荐答案

                  To get Title: from message payload

                  To get the Title: from message payload

                  使用:

                  @Override
                  public void onMessageReceived(RemoteMessage remoteMessage) {
                  
                  
                      Log.d(TAG, "From: " + remoteMessage.getFrom());
                  
                      // Check if message contains a data payload.
                      //In case when notification was send in "notification" parameter we need to check wheather data is null or not.
                      if (remoteMessage.getData()!=null && remoteMessage.getData().size() > 0) {
                          Log.d(TAG, "Message data payload: " + remoteMessage.getData());
                          String title = remoteMessage.getData().get("title").toString();
                      }
                  
                  
                  }
                  

                  编辑

                  检查你的 remoteMessage 是否包含特定的键:

                  check if your remoteMessage contain the specific key:

                  if (remoteMessage.getData()!=null){
                   for (Map.Entry<String, String> entry : remoteMessage.getData().entrySet()) {
                      String key = entry.getKey();
                      String value = entry.getValue();
                      Log.d(TAG, "key, " + key + " value " + value);
                  }}
                  

                  这篇关于如何从 Android 中的 FCM 数据消息中获取价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
                  cocos2d-android: how to display score(cocos2d-android:如何显示分数)
                  Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                  SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                  Android file copy(安卓文件拷贝)
                  Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)
                      <bdo id='fU3DU'></bdo><ul id='fU3DU'></ul>
                        <tbody id='fU3DU'></tbody>

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

                      2. <small id='fU3DU'></small><noframes id='fU3DU'>