gpt4 book ai didi

c# - PushSharp APNS 通知错误请求的功能不受支持

转载 作者:行者123 更新时间:2023-11-30 12:38:10 25 4
gpt4 key购买 nike

我正在使用 PushSharp 4.0.10在 Apns 代理的 OnNotificationFailed 事件中,我收到“不支持请求的功能”异常。有我的 Broker 创建者

private static ApnsServiceBroker CreateApnsBroker(string certificate)
{
// Configuration (NOTE: .pfx can also be used here)
var config = newApnsConfiguration(
ApnsConfiguration.ApnsServerEnvironment.Sandbox,
certificate,
ConfigurationManager.AppSettings["Cert_Passwd"],
false);

// Create a new broker
var apnsBroker = new ApnsServiceBroker(config);

// Wire up events
apnsBroker.OnNotificationFailed += (notification, aggregateEx) =>
{
aggregateEx.Handle(ex =>
{
// See what kind of exception it was to further diagnose
if (ex is ApnsNotificationException notificationException)
{
// Deal with the failed notification
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;

Logger.Info($"Apple Notification Failed:
ID={apnsNotification.Identifier},
Code={statusCode}",
ex);
}
else
{
// Inner exception might hold more useful information
// like an ApnsConnectionException
Logger.Info($"Apple Notification Failed for some unknown reason:
{ex.InnerException}",
ex);
}
// Mark it as handled
return true;
});
};

apnsBroker.OnNotificationSucceeded += (notification) =>
{
Logger.Info($"Apple Notification Sent for device {notification.DeviceToken}");
};

return apnsBroker;
}

发送通知

private static void QueueNotification(
ApnsServiceBroker apnsBroker,
string deviceToken,
string payload)
{
// Queue a notification to send
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = deviceToken,
Payload = JObject.Parse(payload),
Expiration = DateTime.Now.AddDays(2)
});
}

当我在 OnNotificationFailed 中停止代理时捕获异常。在 PushSharp 和我的代码中,我使用 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12使用 .p12 证书进行 voip 通知,它已添加到 mmc 中我的错误是什么?

最佳答案

我克隆了 PushSharp 存储库,编译了本地 dll,更改了项目链接并且成功了,但我不知道为什么。

关于c# - PushSharp APNS 通知错误请求的功能不受支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55099284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com