Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios PUSHARP Apns通知错误:';连接错误';_Ios_Asp.net Mvc 4_Push Notification_Pushsharp_Apn - Fatal编程技术网

Ios PUSHARP Apns通知错误:';连接错误';

Ios PUSHARP Apns通知错误:';连接错误';,ios,asp.net-mvc-4,push-notification,pushsharp,apn,Ios,Asp.net Mvc 4,Push Notification,Pushsharp,Apn,我正在使用PushSharp 4.0.10,MVC4和c# 在Apns代理的OnNotificationFailed事件中,我得到ConnectionError异常。 此异常在更改证书(.p12)文件后突然发生;在这一变化之前,它运行良好。 请告知如何排除此错误 var certificate = System.IO.File.ReadAllBytes(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Mobile/consumer

我正在使用PushSharp 4.0.10,MVC4和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();

尝试只将前两个参数传递给apnsconfiguration构造函数,或者删除validateIsApnsCertificate(bool)参数。 前三个参数对我来说效果很好

var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Production, appleCert, P12Password);

此错误是因为您使用的证书未启用

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


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

我遇到了相同的问题,但这对我不起作用。您找到解决方案了吗?