简体   繁体   中英

UNUserNotification iOS 11: Dismiss single notification, not all

I built a simple todo app based on the reminders app and EKEvent. Instead of setting an EKAlert for their due date, I built my own UNUserNotification, mainly because of custom action events I'd like to have. The code mainly follows the examples on this page: https://useyourloaf.com/blog/local-notifications-with-ios-10/

For testing, the app is also scheduling EKAlarms with the same parameters. Now if I test with 2 todo entries like this:

  • todo test 1, due date 10:00 am
  • todo test 2, due date 10:00 am

I get 2 UserNotifications and 2 EKAlarm reminders in notification center at 10am. Now my Problem:

  • If one of the EKAlarms is dismissed / acted upon, it disappears from notification center, while the other alarm stays there.
  • If one of the UNUserNotifications is dismissed / acted upon, all other notifications disappear as well from notification center.

I'd rather act on every todo on it's own: Some I want to dismiss, some to snooze, some to ignore altogether, all in notification center.

I tried:

  • attempting to check all options regarding notifications in iOS, particularly the app-specific ones
  • setting a unique external identifier as well as a unique UNNotificationCategory for each UserNotification, which had no effect - all notifications disappear regardless
  • googling if someone else has encountered this problem, but all I could find was complaints about older iOS versions NOT dismissing all notifications at once.

So is there a way to schedule multiple notifications from an app, but have the user dismiss every single one of them?

Thanks!

EDIT: this post suggests that the Problem is related to iOS 11 specifically. I think it describes my problem well, but way shorter :)

EDIT 2: This appears to be a problem with iOS 11.2.x. This radar: https://openradar.appspot.com/36019616 exactly describes my problem.

EDIT 3: As of iOS 11.2.6, the behaviour hasn't changed.

EDIT 4: No change of behaviour in iOS 11.3.

EDIT 5: No change in iOS 11.4.

EDIT 6: Finally! The iOS12 update "stacks" notifications together. I can now handle every single alert/reminder the app is firing.

content.body添加一些文本:

content.body = 'Any text'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM