Missing Push Notifications (#1696): Show a notification even if the app fails to sync with its hs to get all data.

Show notif on /sync failure callback too
This commit is contained in:
manuroe 2017-12-29 13:33:55 +01:00
parent 9e612dd7d0
commit 750a6e9784

View file

@ -1200,9 +1200,12 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
{
NSLog(@"[AppDelegate][Push] launchBackgroundSync");
__weak typeof(self) weakSelf = self;
NSMutableArray<NSString *> *incomingPushEventIds = self.incomingPushEventIds[@(account.mxSession.hash)];
NSMutableArray<NSString *> *incomingPushEventIdsCopy = [incomingPushEventIds copy];
// Flush all the pending push notifications for this session.
[self.incomingPushEventIds[@(account.mxSession.hash)] removeAllObjects];
[incomingPushEventIds removeAllObjects];
[account backgroundSync:20000 success:^{
@ -1223,7 +1226,13 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
} failure:^(NSError *error) {
NSLog(@"[AppDelegate][Push] launchBackgroundSync: the background sync failed for %tu pending notifications. Error: %@ (%@)", self.incomingPushEventIds[@(account.mxSession.hash)].count, error.domain, @(error.code));
NSLog(@"[AppDelegate][Push] launchBackgroundSync: the background sync failed. Error: %@ (%@). incomingPushEventIdsCopy: %@ - self.incomingPushEventIds: %@", error.domain, @(error.code), incomingPushEventIdsCopy, incomingPushEventIds);
// Trigger local notifications when the sync with HS fails
[self handleLimitedLocalNotifications:account.mxSession events:incomingPushEventIdsCopy];
// Update app icon badge number
[self refreshApplicationIconBadgeNumber];
}];
}