在這裏你去,你也需要注意,如果您的證書是督促/開發 依賴,在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));