【问题标题】:NotificationHub in Xamarin form: How to tell is the notification has been sentXamarin 形式的 NotificationHub:如何判断通知是否已发送
【发布时间】: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


    【解决方案1】:

    在我看来,我认为 NotificationOutcome.Success 值意味着消息的NotificationOutcomeState 的值已完成。

    已完成:收到发送的通知时的NotificationOutcome

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-15
      相关资源
      最近更新 更多