我正在使用下面提到的代码但是我收到了错误:
指定的参数超出了有效值的范围。 参数名称:您的证书不是用于连接Apple的APNS服务器的有效证书
我想使用asp.net MVC向iOS设备发送通知。我正在使用push sharp library发送通知。
答案 0 :(得分:1)
在这里,如果您的证书是Prod / Dev,您还需要注意
取决于ApplePushChannelSettings
方法,你的第一个参数是真的=如果证书是生产
false =如果证书是开发
broker = new PushBroker();
broker.OnNotificationSent += _broker_OnNotificationSentApple;
broker.OnChannelException += _broker_OnChannelExceptionApple;
broker.OnServiceException += _broker_OnServiceExceptionApple;
broker.OnNotificationFailed += _broker_OnNotificationFailedApple;
broker.OnDeviceSubscriptionExpired += _broker_OnDeviceSubscriptionExpiredApple;
broker.OnDeviceSubscriptionChanged += _broker_OnDeviceSubscriptionChangedApple;
broker.OnChannelCreated += _broker_OnChannelCreatedApple;
broker.OnChannelDestroyed += _broker_OnChannelDestroyedApple;
byte[] appleCert = File.ReadAllBytes(the path to the certificate);
broker.RegisterAppleService(new PushSharp.Apple.ApplePushChannelSettings(false,appleCert, appCertPassword,false),null);/
broker.QueueNotification(new AppleNotification()
.ForDeviceToken(yourDeviceToken)
.WithAlert(message)
.WithBadge(0));