Merge pull request #1694 from vector-im/more_logs_for_notifications

Push Notifications: Add more logs to track possible lost notifications
This commit is contained in:
manuroe 2017-12-15 11:23:00 +01:00 committed by GitHub
commit d019f65b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1199,6 +1199,8 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
{
NSLog(@"[AppDelegate] handleLocalNotificationsForAccount: %@", account.mxCredentials.userId);
NSUInteger scheduledNotifications = 0;
// The call invite are handled here only when the callkit is not active.
BOOL isCallKitActive = [MXCallKitAdapter callKitAvailable] && [MXKAppSettings standardAppSettings].isCallKitEnabled;
@ -1223,6 +1225,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
// Ignore redacted event.
if (event.isRedactedEvent)
{
NSLog(@"[AppDelegate] handleLocalNotificationsForAccount: Skip redacted event");
continue;
}
@ -1232,6 +1235,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
// Ignore call invite when callkit is active.
if (isCallKitActive)
{
NSLog(@"[AppDelegate] handleLocalNotificationsForAccount: Skip call event");
continue;
}
else
@ -1257,6 +1261,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
MXEvent *readReceiptEvent = [account.mxSession.store eventWithEventId:readReceipt.eventId inRoom:roomId];
if (event.originServerTs <= readReceiptEvent.originServerTs)
{
NSLog(@"[AppDelegate] handleLocalNotificationsForAccount: Skip already read event");
continue;
}
}
@ -1291,19 +1296,29 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
}
}
}
[[UIApplication sharedApplication] scheduleLocalNotification:eventNotification];
scheduledNotifications++;
}
else
{
NSLog(@"[AppDelegate] handleLocalNotificationsForAccount: Skip event with empty generated notificationBody. Event id: %@", event.eventId);
}
}
}
NSLog(@"[AppDelegate] handleLocalNotificationsForAccount: Sent %tu local notifications for %tu events", scheduledNotifications, eventsArray.count);
[eventsArray removeAllObjects];
}
- (nullable NSString *)notificationBodyForEvent:(MXEvent *)event pushRule:(MXPushRule*)rule inAccount:(MXKAccount*)account
{
if (!event.content || !event.content.count)
{
NSLog(@"[AppDelegate] notificationBodyForEvent: empty event content");
return nil;
}
MXRoom *room = [account.mxSession roomWithRoomId:event.roomId];
MXRoomState *roomState = room.state;
@ -1339,6 +1354,7 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
if (!isHighlighted)
{
// Ignore this notif.
NSLog(@"[AppDelegate] notificationBodyForEvent: Ignore non highlighted notif in mentions only room");
return nil;
}
}