It is still working for us. I just checked it on iOS 11.2.2.
I am using removeDeliveredNotificationsWithIdentifiers:
inside getDeliveredNotificationsWithCompletionHandler:
, calling getDeliveredNotificationsWithCompletionHandler
on Main Thread.
- (void)removePendingNotificationsForObjectID:(SJFObjectID *)objectID {
__weak __typeof(self) weakSelf = self;
[self.userNotificationCenter getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> *notifications) {
__strong __typeof(weakSelf) self = weakSelf;
NSMutableArray <NSString *> *identifiersToRemove = [@[] mutableCopy];
for (UNNotification *notification in notifications) {
SJFObjectID *objectIDFromNotification = [self.notificationToObjectIDMarshaller marshalNotification:notification];
if ([objectID isEqual:objectIDFromNotification]) {
[identifiersToRemove addObject:notification.request.identifier];
}
}
[self.userNotificationCenter removeDeliveredNotificationsWithIdentifiers:identifiersToRemove];
}];
}
Though I experience strange behavior if I am debugging the completionHandler. If a pause too long (whatever that means) the completion handler will not finish (even on continue process execution) resulting in an unresponsive app. Maybe the completionhandler gets terminated.
SpringBoard(UserNotificationsServer)[62] <Error>: Could not load data at /var/mobile/Library/SpringBoard/PushStore/APP_BUNDLE_STRING.pushstore
followed bySpringBoard(UserNotificationsServer)[62] <Notice>: Saving notification list at /var/mobile/Library/SpringBoard/PushStore/APP_BUNDLE_STRING.pushstore with 0 items
(where APP_BUNDLE_STRING is my app's bundle string) Are you seeing the same? Have you tried a TSI or have you filed a radar? – HawgetDeliveredNotificationsWithCompletionHandler
returned empty array. – Olid