2

I developed an app which heavily depends on local notifications. Since upgrading to ios 11.2.1 the behavior changed without any changes in my code.

In the previous version until 11.2.0, if there were multiple notifications from the same app in notification center and one of those was answered, all other notifications remained (Unless cleaned by the code inside the app) in the notifications center.

After I upgraded to 11.2.1, every time notification is answered, all other notifications are removed as well. I tested on multiple devices in a simulator and on my iPhone 6. This also happens with other apps like Messages or Line, therefore, it is not limited to local notifications only.

Is this a bug in ios 11.2.1 or expected new behavior of notifications? In either case, is there a way to have notifications work the same way as before?

Here is a how relevant code handling answer

- (void)removeNotificationWithIdentifier:(NSString *)identifier {
    NSMutableDictionary *notifications = [self getAllNotifications];
    NSMutableDictionary *categories = [self getAllCategories];
    UNNotificationContent *content = [notifications objectForKey:identifier];
    NSString *category = [content.userInfo objectForKey:@"category"];

    [notifications removeObjectForKey:identifier];

    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    [center removePendingNotificationRequestsWithIdentifiers:[NSArray arrayWithObjects:identifier, nil]];
    [center removeDeliveredNotificationsWithIdentifiers:[NSArray arrayWithObjects:identifier, nil]];

    if (category != nil) {
        [categories removeObjectForKey:category];
    }

    [self saveAllNotifications:notifications];
    [self saveAllCategories:categories];
}
kalpesh satasiya
  • 799
  • 8
  • 18
Petr
  • 183
  • 1
  • 1
  • 11
  • i think this is an expected behaviour. Apple is going crazy these days. Apple ..!. – Pratik Jamariya Dec 26 '17 at 05:46
  • I hope it is not expected behavior. Imagine any messaging app. Until now, if I had messages from 2 users, I could answer to both without even opening the app. It is not possible after this update. – Petr Dec 26 '17 at 06:02
  • i meant its expected if you read correctly. Its Apple does the thing, clearing all notification of same app isn't ideal. WTH Apple? – Pratik Jamariya Dec 26 '17 at 06:05
  • Yeah, what I meant is doing changes to a functions without documenting it is really not expected. But, sadly, it seems to be how things are at Apple now. – Petr Dec 26 '17 at 09:04
  • @Petr did you find any solution to the issue? – Saleh Jan 07 '18 at 16:23
  • @Saleh, not really. I have a workaround for now: I keep track of all notifications, so after one is answered I schedule new notifications for those deleted one with fireDate set to now. – Petr Jan 09 '18 at 16:26

0 Answers0