Fix missing notifications.

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

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

Loading…
Cancel
Save