use*_*999 5 apple-push-notifications pushsharp
我正在使用Push Sharp库将推送通知发送到Apple APN服务器.代码效果很好,我可以发送1000个通知.
问题是,如果我尝试发送带有无效设备令牌的通知,我会收到来自push sharp框架的失败消息,pushsharp.apple.notificationfailureexception并且不会发送在该点之后排队的每个消息.基本上,如果单个通知失败,PushSharp将清除其队列.
例如,如果我排队4个通知(1,2,3,4)并且通知2具有无效的设备令牌,则将发送通知1,2将失败,并且不发送3和4(并且不会触发任何事件通知这个的).
我知道带有无效设备令牌的通知将不会被发送,但是不能接受将其他N个排队通知丢弃在地板上.
这有什么变通方法吗?
这是我的代码:
_appleSettings = new ApplePushChannelSettings(!NOTIFICATION_SERVICE_USE_DEVELOPMENT,
NOTIFICATION_SERVICE_USE_DEVELOPMENT
? SSL_CERTIFICATE_NAME_DEV : SSL_CERTIFICATE_NAME_PROD,
SSL_CERTIFICATE_PASSWORD);
_appleSettings.ConnectionTimeout = NOTIFICATION_SERVICE_CONNECTION_TIMEOUT;
_appleSettings.FeedbackIntervalMinutes = 0; /*WE WILL HANDLE THE FEEDBACK EXTERNALLY*/
_appleSettings.MaxConnectionAttempts = NOTIFICATION_SERVICE_RETRY_ATTEMPS;
_serviceSettings = new PushServiceSettings();
_serviceSettings.MaxAutoScaleChannels = NOTIFICATION_SERVICE_NUM_CONNECTIONS;
_pushBroker = new PushBroker();
_pushBroker.OnChannelCreated += _pushBroker_OnChannelCreated;
_pushBroker.OnChannelDestroyed += _pushBroker_OnChannelDestroyed;
_pushBroker.OnChannelException += _pushBroker_OnChannelException;
_pushBroker.OnDeviceSubscriptionChanged += _pushBroker_OnDeviceSubscriptionChanged;
_pushBroker.OnDeviceSubscriptionExpired += _pushBroker_OnDeviceSubscriptionExpired;
_pushBroker.OnNotificationFailed += _pushBroker_OnNotificationFailed;
_pushBroker.OnNotificationRequeue += _pushBroker_OnNotificationRequeue;
_pushBroker.OnNotificationSent += _pushBroker_OnNotificationSent;
_pushBroker.OnServiceException += _pushBroker_OnServiceException;
//now add those settings to the push broker
_pushBroker.RegisterAppleService(_appleSettings, _serviceSettings);
notification = new AppleNotification(notificationMessage.DeviceExtContext);
notification.Payload.Alert.Body = notificationMessage.Message;
notification.Payload.Sound = NOTIFICATION_SOUND;
// notification.Payload.Badge = 1;
notification.Tag = notificationMessage;
//attempt to queue the notification
_pushBroker.QueueNotification(notification);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
956 次 |
| 最近记录: |