2017-10-28 93 views
0

我正在使用NotificationHub向具有tag_12标签的设备发送基本待处理预订消息。Xamarin格式的NotificationHub:如何判断通知是否已发送

var apsOutcome = await PushNotification(Apple, tag, siteId, message); 
if (apsOutcome.Success > 0) 
{ 
    siteBookings.BookingList.ForEach(y => y.IsApsSend = true); 
} 

我可以用它来发送消息,但不知道NotificationOutcome是如何工作的。

我有数据返回NotificationOutcome.Success = 2,而其他一些数据恢复成功= 0,失败= 0

是什么2代表什么?它是NotificationOutcomeState.Process,但是NotificationOutcomeState.Completed呢?

private async Task<NotificationOutcome> PushNotification(string pns, string tagExpression, int siteId, string message) 
    { 
     var outcome = new NotificationOutcome(); 

     switch (pns) 
     { 
      case Apple: 
       var payload1 = String.Format("\"alert\" : \"{0}\", \"siteId\": {1}, \"message\" : \"{2}\"", message, siteId, message); 
       var apsPayload = String.Format("\"aps\" : {0}", "{"+payload1+"}"); 
       outcome = await hubClient.SendAppleNativeNotificationAsync("{"+apsPayload+"}", tagExpression); 
        break; 
      case FireBase: 
       var payload2 = "{" + String.Format("\"siteId\": {0}, \"message\" : \"{1}\" ", siteId, message) + "}"; 
       var fireBasePayload = "{" + String.Format("\"data\" : {0}", payload2) + "}"; 
       outcome = await hubClient.SendGcmNativeNotificationAsync(fireBasePayload, tagExpression); 
       break; 
     } 

     return outcome; 
    } 

回答

0

在我看来,我觉得NotificationOutcome.Success值指的是消息的NotificationOutcomeState是已完成的价值。

完成:当发送的通知已经recevied

它意味着“由相应的推送通知服务接收到的” NotificationOutcome。如果它是iOS设备,它将被“APNS接收”。

相关问题