Fix missing notifications.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent 4b655a7019
commit fc7dec04aa

@ -219,7 +219,7 @@
// Replace any existing notification
// e.g. when an "Incoming Call" notification gets replaced with a "Missed Call" notification.
if (self.currentNotifications[identifier]) {
[self cancelNotificationWithIdentifier:identifier];
[self cancelNotificationWithIdentifierMainThread:identifier];
}
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
@ -232,18 +232,24 @@
- (void)cancelNotificationWithIdentifier:(NSString *)identifier
{
dispatch_async(dispatch_get_main_queue(), ^{
UILocalNotification *notification = self.currentNotifications[identifier];
if (!notification) {
DDLogWarn(
@"%@ Couldn't cancel notification because none was found with identifier: %@", self.tag, identifier);
return;
}
[self.currentNotifications removeObjectForKey:identifier];
[[UIApplication sharedApplication] cancelLocalNotification:notification];
[self cancelNotificationWithIdentifierMainThread:identifier];
});
}
- (void)cancelNotificationWithIdentifierMainThread:(NSString *)identifier
{
OWSAssert([NSThread isMainThread]);
UILocalNotification *notification = self.currentNotifications[identifier];
if (!notification) {
DDLogWarn(@"%@ Couldn't cancel notification because none was found with identifier: %@", self.tag, identifier);
return;
}
[self.currentNotifications removeObjectForKey:identifier];
[[UIApplication sharedApplication] cancelLocalNotification:notification];
}
#pragma mark - Logging
+ (NSString *)tag

Loading…
Cancel
Save