使用 PushSharp 2.2.1.0 发送通知时出错 iOS
error while sending notification using PushSharp 2.2.1.0 iOS
我正在使用 PushSharp 版本 2.2.1.0,并为 iOS 引用 "PushSharp.Core" 和 "PushSharp.Apple" 库。
我已经删除了防火墙的所有限制,因为它涉及一些安全问题。
我已经使用密钥或不使用密钥从设备导出了证书。在发送通知时,我的代码卡在 PushBroker class.And 的 stopAllServices() 方法中,在某些情况下我设置了 ApplePushChannelSettings 的 SkipSsl=true(我没有使用 ssl),我收到错误 "Credentials supplied to the package were not recognized"很久以前也在这里发过:https://code.google.com/p/apns-sharp/issues/detail?id=3。
达到这种方法后,我的程序被绞死了。
这是我的代码:
//Create our push services broker
var push = new PushBroker();
//Wire up the events for all the services that the broker registers
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
var appleCert = File.ReadAllBytes(FileHelper.CERTIFICATEFILE);
X509Certificate2 Cert = new X509Certificate2(appleCert, FileHelper.PASSWORD, X509KeyStorageFlags.MachineKeySet);
push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, FileHelper.PASSWORD));
push.QueueNotification(new AppleNotification()
.ForDeviceToken(DeviceID.ToUpper()/*my device id*/)
.WithAlert("my message")
.WithSound("default")
.WithBadge(1)
.WithCustomItem("status", new object[] { "sucess") })
.WithCustomItem("identifier", new object[] { "1"}));
push.StopAllServices();
我也试过使用无密码证书。它触发 ChannelCreated,然后到达 ServiceException。
我发现它在使用没有密码的证书时有效。
我正在使用 PushSharp 版本 2.2.1.0,并为 iOS 引用 "PushSharp.Core" 和 "PushSharp.Apple" 库。 我已经删除了防火墙的所有限制,因为它涉及一些安全问题。
我已经使用密钥或不使用密钥从设备导出了证书。在发送通知时,我的代码卡在 PushBroker class.And 的 stopAllServices() 方法中,在某些情况下我设置了 ApplePushChannelSettings 的 SkipSsl=true(我没有使用 ssl),我收到错误 "Credentials supplied to the package were not recognized"很久以前也在这里发过:https://code.google.com/p/apns-sharp/issues/detail?id=3。 达到这种方法后,我的程序被绞死了。 这是我的代码:
//Create our push services broker
var push = new PushBroker();
//Wire up the events for all the services that the broker registers
push.OnNotificationSent += NotificationSent;
push.OnChannelException += ChannelException;
push.OnServiceException += ServiceException;
push.OnNotificationFailed += NotificationFailed;
push.OnDeviceSubscriptionExpired += DeviceSubscriptionExpired;
push.OnDeviceSubscriptionChanged += DeviceSubscriptionChanged;
push.OnChannelCreated += ChannelCreated;
push.OnChannelDestroyed += ChannelDestroyed;
var appleCert = File.ReadAllBytes(FileHelper.CERTIFICATEFILE);
X509Certificate2 Cert = new X509Certificate2(appleCert, FileHelper.PASSWORD, X509KeyStorageFlags.MachineKeySet);
push.RegisterAppleService(new ApplePushChannelSettings(false, appleCert, FileHelper.PASSWORD));
push.QueueNotification(new AppleNotification()
.ForDeviceToken(DeviceID.ToUpper()/*my device id*/)
.WithAlert("my message")
.WithSound("default")
.WithBadge(1)
.WithCustomItem("status", new object[] { "sucess") })
.WithCustomItem("identifier", new object[] { "1"}));
push.StopAllServices();
我也试过使用无密码证书。它触发 ChannelCreated,然后到达 ServiceException。
我发现它在使用没有密码的证书时有效。