我正在使用下面提到的这段代码,但出现错误:
Specified argument was out of the range of valid values. Parameter name: Your Certificate is not a valid certificate for connecting to Apple's APNS servers
我想使用 asp.net MVC 向 iOS 设备发送通知。我正在使用 push sharp 库发送通知。
最佳答案
给你,如果你的证书是Prod/Dev,你也需要注意
取决于在 ApplePushChannelSettings
方法中你的第一个参数是 true= if certificate is production
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));
关于ios - 如何使用c#在ios上发送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43600880/