【问题标题】:Body of GCM notification always displays as <missing message content> when using PushSharp使用 PushSharp 时,GCM 通知正文始终显示为 <missing message content>
【发布时间】:2016-05-23 05:08:33
【问题描述】:

我使用的是 PushSharp 4.0.1 版,目前当我发送通知时,标题显示正常,但消息正文始终显示为“”。如果我不使用 PushSharp 直接从 Postman 向 GCM 发送测试消息,则内容显示正常。下面是我构建消息正文的方式。任何想法都会很棒!

   gcmBroker.QueueNotification(new GcmNotification
   {
       RegistrationIds = new List<string>
       {
         token
       },
       Data = JObject.Parse("{ \"title\" : \""+ message.PatientFirstName +" "+ message.PatientLastName + ". " + message.GlucoseMeasurement.TrendArrow +"\"," +
                            " \"body\" : \""+ message.GlucoseMeasurement.ValueInMgPerDl + "at" + message.GlucoseMeasurement.Timestamp + "\"," +
                            " \"icon\" : \"icon\"," +
                            " \"color\" : \"#FF4081\"}")
    });

【问题讨论】:

    标签: c# asp.net .net google-cloud-messaging pushsharp


    【解决方案1】:

    实际上是在深入研究 GCM 文档后才弄明白的。自从我使用Dataparam 以来,我试图在不知不觉中发送数据通知。代码应该看起来像这样......

                gcmBroker.QueueNotification(new GcmNotification
                {
                    RegistrationIds = new List<string>
                    {
                        token
                    },
                    Notification = JObject.Parse("{ \"title\" : \"" + message.PatientFirstName + " " + message.PatientLastName + ". " + message.GlucoseMeasurement.TrendArrow + "\"," +
                                         " \"body\" : \"" + message.GlucoseMeasurement.ValueInMgPerDl + " at " + message.GlucoseMeasurement.Timestamp + "\"," +
                                         " \"icon\" : \"icon\"," +
                                         " \"color\" : \"#FF4081\"}")
                });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-11
      • 1970-01-01
      • 2018-06-12
      相关资源
      最近更新 更多