使用 PushSharp 时,GCM 通知的 Body 始终显示为 <missing message content>

Body of GCM notification always displays as <missing message content> when using PushSharp

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

   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\"}")
    });

在深入研究 GCM 文档后,实际上最终弄明白了。我试图在不知不觉中发送数据通知,因为我正在使用 Data 参数。代码应该看起来像这样...

            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\"}")
            });