无法通过临时分发的 pushsharp 发送推送通知
Cannot send push notifications via pushsharp on adhoc distribution
我正在使用 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 文件。
有人遇到过问题吗?
好吧,我终于通过将证书 导出为 .p12 文件,然后将该文件与 PushSharp 一起使用来实现它。
我正在使用 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 文件。
有人遇到过问题吗?
好吧,我终于通过将证书 导出为 .p12 文件,然后将该文件与 PushSharp 一起使用来实现它。