【发布时间】: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) 为生产环境配置了基于令牌的身份验证。
另外,我试过了:
- Azure 推送通知中心基于证书的身份验证;
- enableTestSend 以获得更好的调试体验。结果通知结果为“成功”;
- 增加了 Azure 推送到 S1 的计划,以获得更好的调试体验。结果通知结果也是“成功”;
- 重新创建推送通知中心;
- 删除所有现有安装;
- 已在 5 台不同的设备上完成了测试。
问题:
- 有没有办法在 Azure 通知中心之外调试未传递的推送通知?
- 在这种情况下,什么会导致推送通知无法发送?
【问题讨论】:
标签: azure asp.net-core push-notification apple-push-notifications azure-notificationhub