无法在临时分发上通过 pushsharp 发送推送通知
Posted
技术标签:
【中文标题】无法在临时分发上通过 pushsharp 发送推送通知【英文标题】:Cannot send push notifications via pushsharp on adhoc distribution 【发布时间】:2016-06-23 20:39:51 【问题描述】:我正在使用 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 ();
我很确定它与证书以及如何生成它们有关。到目前为止我做了什么:
创建新的分发证书 创建新的 APS 生产证书 创建临时分发配置文件 全部安装在我的 mac 上 使用分发证书代码签名和临时配置文件归档应用程序。 将其导出以进行临时分发 在授权设备上安装应用程序 使用正确的密码从证书私钥中导出了一个 .p12 文件。有人遇到过问题吗?
【问题讨论】:
【参考方案1】:好吧,我终于通过将证书导出为 .p12 文件,然后将该文件与 PushSharp 一起使用来实现它。
【讨论】:
以上是关于无法在临时分发上通过 pushsharp 发送推送通知的主要内容,如果未能解决你的问题,请参考以下文章
证书的 iOS 推送通知 AuthenticationException