我正在使用PushSharp向应用发送iOS通知。
我已经设法在示例后的开发环境中使其工作,但是当我尝试在生产环境中发送它时,我收到以下错误:
InnerException = {"No se pudo realizar una llamada a SSPI; consulte la excepción interna."
{"SSL Stream Failed to Authenticate as Client"}
以下是代码:
var config = new ApnsConfiguration(ApnsConfiguration.ApnsServerEnvironment.Sandbox, "path/to/file", "MyPassword", 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) {
var notificationException = (ApnsNotificationException)ex;
// Deal with the failed notification
var apnsNotification = notificationException.Notification;
var statusCode = notificationException.ErrorStatusCode;
Console.WriteLine ("Apple Notification Failed: ID={apnsNotification.Identifier}, Code={statusCode}");
} else {
// Inner exception might hold more useful information like an ApnsConnectionException
Console.WriteLine ("Apple Notification Failed for some unknown reason : {ex.InnerException}");
}
// Mark it as handled
return true;
});
};
apnsBroker.OnNotificationSucceeded += (notification) => {
Console.WriteLine ("Apple Notification Sent!");
};
// var i = JObject.FromObject(push);
// Start the broker
apnsBroker.Start ();
apnsBroker.QueueNotification(new ApnsNotification
{
DeviceToken = "somedevicetokenthatiusetotest",
Payload = JObject.Parse("{\"aps\":{\"alert\":\"My custom alert\",\"badge\":\"1\"}, \"date\": \"2016-06-07T01:38:00.541Z\"}"),
});
// Stop the broker, wait for it to finish
// This isn't done after every message, but after you're
// done with the broker
apnsBroker.Stop ();
我非常确定它与证书有关,我如何生成它们。到目前为止我做了什么:
有人遇到过问题吗?
答案 0 :(得分:1)
好吧,我终于通过将仅将证书导出为.p12文件,然后将该文件与PushSharp一起使用来使其工作。