2017-04-25 64 views
1

IOS通知我用這個代碼,我下面提,但我得到了一個錯誤:如何發送使用C#

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設備發送通知。我正在使用尖銳的庫來發送通知。

回答

1

在這裏你去,你也需要注意,如果您的證書是督促/開發 依賴,在ApplePushChannelSettings方法的第一個參數是真=證書是否生產
假=證書是否發展

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));