ios - 如何使用c#在ios上发送通知

标签 ios pushsharp

我正在使用下面提到的这段代码,但出现错误:

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/

相关文章:

ios - iOS Swift 中的 Android 选项卡

iOS图层位置

push-notification - 应用程序在后台时的 ngCordova/Ionic 推送通知

c# - 如何在不排队的情况下从 C# 发送 APNS 推送通知 (iOS)

ios - Xcode 4.2.1 Storyboard 多对一 View 返回

ios - 用于本地化的字符串比较

c# - PushSharp APNS 反馈服务示例

c# - Apns c# 异常无法从传输连接读取数据现有连接被远程主机强行关闭

ios - 如何找到自动增长的 UILabel 的实际高度

c# - PushSharp 是否允许向 iOS 版 GCM 发送通知?