【问题标题】:how to send notification on ios using c#如何使用 c# 在 ios 上发送通知
【发布时间】:2017-04-25 03:05:03
【问题描述】:

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

指定的参数超出了有效值的范围。 参数名称:您的证书不是连接苹果APNS服务器的有效证书

我想使用 asp.net MVC 向 iOS 设备发送通知。我正在使用 push sharp 库来发送通知。

【问题讨论】:

    标签: ios pushsharp


    【解决方案1】:

    给你,如果你的证书是 Prod/Dev,你也需要注意 取决于 ApplePushChannelSettings 方法中的第一个参数是 true= 如果证书是生产
    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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-22
      • 1970-01-01
      相关资源
      最近更新 更多