【问题标题】:Why iOS devices might not receive push notifications from Azure push notification hub?为什么 iOS 设备可能不会收到来自 Azure 推送通知中心的推送通知?
【发布时间】:2020-08-22 17:00:03
【问题描述】:

问题

我想在 iOS 设备上接收推送通知,这些是从我的 web api 发送的,但从未收到推送通知。

从 API 发送的所有通知都在 Azure 推送通知指标中显示为发送成功,但设备未收到。

但是,如果从 Azure 推送通知中心发送推送通知,通过测试发送,通知发送和接收成功。

配置:

Web API 配置:
.NET Core 2.2 Web API
Nuget 从 Web api 发送推送通知:Microsoft.Azure.NotificationHubs
所有设备都从 web api 端点注册为安装。

await _hubClient.CreateOrUpdateInstallationAsync(new Installation()
{
    Tags = installation.Tags,
    Platform = NotificationPlatform.Apns,
    PushChannel = installation.PushChannel,
    InstallationId = Guid.NewGuid().ToString()
});

使用原生方式发送推送通知。

var headers = new Dictionary<string, string>
{
    { "apns-push-type", "alert" },
    { "apns-priority", "5" }
};
var message = "{\"Aps\":{\"Alert\":\"Notification Hub test notification\"}}";
var tagExpression = newNotification.Tags.Aggregate((first, second) => $"{first} || {second}");
var notification = new AppleNotification(message, headers);
outcome = await _hubClient.SendNotificationAsync(notification, tagExpression, CancellationToken.None);

我也尝试过以下方法,但结果相同:

await _hubClient.SendAppleNativeNotificationAsync(newNotification.Content, tagExpression);

天蓝色:
Azure 通知中心 Apple (APNS) 为生产环境配置了基于令牌的身份验证。

另外,我试过了:

  1. Azure 推送通知中心基于证书的身份验证;
  2. enableTestSend 以获得更好的调试体验。结果通知结果为“成功”;
  3. 增加了 Azure 推送到 S1 的计划,以获得更好的调试体验。结果通知结果也是“成功”;
  4. 重新创建推送通知中心;
  5. 删除所有现有安装;
  6. 已在 5 台不同的设备上完成了测试。

问题:

  1. 有没有办法在 Azure 通知中心之外调试未传递的推送通知?
  2. 在这种情况下,什么会导致推送通知无法发送?

【问题讨论】:

    标签: azure asp.net-core push-notification apple-push-notifications azure-notificationhub


    【解决方案1】:

    好的,我的问题很快就解决了:)

    如果有人想知道,APNS 模板中有错字。它不是骆驼案。
    错误:

    "{\"Aps\":{\"Alert\":\"Notification Hub test notification\"}}"
    

    好:

    "{\"aps\":{\"alert\":\"Notification Hub test notification\"}}"
    

    【讨论】:

      猜你喜欢
      • 2016-07-22
      • 2017-06-05
      • 1970-01-01
      • 2018-01-20
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      • 1970-01-01
      • 2015-02-09
      相关资源
      最近更新 更多