gpt4 book ai didi

ios - PushSharp Apns 通知错误 : 'ConnectionError'

转载 作者:可可西里 更新时间:2023-11-01 04:50:20 28 4
gpt4 key购买 nike

我正在使用 PushSharp 4.0.10,MVC 4 和 c#
在 Apns 代理的 OnNotificationFailed 事件中,我得到 ConnectionError 异常。
更改证书(.p12)文件后突然发生此异常;在此更改之前它运行良好。
请告知如何解决此错误。

var certificate = System.IO.File.ReadAllBytes(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Mobile/consumer_dev.p12"));

var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, certificate, "", true);

var apnsBroker = new ApnsServiceBroker(config);

apnsBroker.OnNotificationFailed += (notification, aggregateEx) => {
aggregateEx.Handle (ex => {
if (ex is ApnsNotificationException) {
var notificationException = (ApnsNotificationException)ex;
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;

Debug.WriteLine(apnsNotification.Identifier + ", " + statusCode);
} else {
Debug.WriteLine(ex.InnerException);
}
return true;
});
};

apnsBroker.OnNotificationSucceeded += (notification) => {
Debug.WriteLine("Apple Notification Sent!");
};

apnsBroker.Start();

foreach (var deviceToken in to)
{
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = deviceToken,
Payload = JObject.Parse("{\"aps\":" + aps.ToString().Replace('=', ':') + "}")
});
}

apnsBroker.Stop();

最佳答案

此错误是因为您使用的证书未启用推送通知。

您必须从 apple id 启用它,然后创建新证书 (.12) 和配置文件。

尝试使用该新证书将解决您的错误。

关于ios - PushSharp Apns 通知错误 : 'ConnectionError' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38117258/

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