コード例 #1
0
 protected override void BrokerInstOnOnNotificationFailed(GcmNotification notification,
                                                          AggregateException exception)
 {
     base.BrokerInstOnOnNotificationFailed(notification, exception);
     exception.Handle(ex =>
     {
         if (ex is GcmNotificationException)
         {
             int count;
             if (WorkingQueue.TryGetValue(notification, out count) && count < TriesCount)
             {
                 RetryQueue(notification);
             }
             else
             {
                 Logger.NotificationFailed(notification, exception);
             }
         }
         else if (ex is GcmMulticastResultException)
         {
             RemoveNotification(notification);
             Logger.NotificationFailed(notification, exception);
         }
         else if (ex is DeviceSubscriptionExpiredException)
         {
             //TODO: Add notification expired logic
             var exc = ex as DeviceSubscriptionExpiredException;
             if (exc.NewSubscriptionId != null)
             {
                 notification.RegistrationIds.Remove(exc.OldSubscriptionId);
                 notification.RegistrationIds.Add(exc.NewSubscriptionId);
                 RetryQueue(notification);
             }
             else
             {
                 Logger.NotificationFailed(notification, exception);
             }
             TokenExperation.AddExpiredToken(exc.OldSubscriptionId, exc.NewSubscriptionId);
         }
         else if (ex is RetryAfterException)
         {
             RemoveNotification(notification);
             Logger.NotificationFailed(notification, exception);
         }
         else
         {
             int count;
             if (WorkingQueue.TryGetValue(notification, out count) && count < TriesCount)
             {
                 RetryQueue(notification);
             }
             else
             {
                 Logger.NotificationFailed(notification, exception);
             }
         }
         return(true);
     });
 }
コード例 #2
0
 protected override void BrokerInstOnOnNotificationFailed(ApnsNotification notification,
                                                          AggregateException exception)
 {
     base.BrokerInstOnOnNotificationFailed(notification, exception);
     exception.Handle(ex =>
     {
         if (ex is ApnsNotificationException)
         {
             int count;
             if (WorkingQueue.TryGetValue(notification, out count) && count < TriesCount)
             {
                 RetryQueue(notification);
             }
             else
             {
                 TokenExperation.AddExpiredToken(notification.DeviceToken, null);
                 Logger.NotificationFailed(notification, ex);
             }
         }
         return(true);
     });
 }