【发布时间】:2018-04-09 19:02:36
【问题描述】:
我正在使用 NotificationHub 向标签为 tag_12 的设备发送基本的待定预订消息。
var apsOutcome = await PushNotification(Apple, tag, siteId, message);
if (apsOutcome.Success > 0)
{
siteBookings.BookingList.ForEach(y => y.IsApsSend = true);
}
我可以使用它来发送消息,但不确定 NotificationOutcome 是如何工作的。
我有数据返回 NotificationOutcome.Success = 2 而其他一些数据返回 Success = 0 和 Failure = 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;
}
【问题讨论】:
标签: azure xamarin.forms azure-notificationhub