简体   繁体   English

UNUserNotification iOS 11:关闭单个通知,而不是全部

[英]UNUserNotification iOS 11: Dismiss single notification, not all

I built a simple todo app based on the reminders app and EKEvent. 我基于提醒应用程序和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. 我没有设置EKAlert的截止日期,而是构建了自己的UNUserNotification,这主要是因为我希望拥有自定义操作事件。 The code mainly follows the examples on this page: https://useyourloaf.com/blog/local-notifications-with-ios-10/ 该代码主要遵循此页面上的示例: https : //useyourloaf.com/blog/local-notifications-with-ios-10/

For testing, the app is also scheduling EKAlarms with the same parameters. 为了进行测试,该应用程序还计划使用相同的参数来调度EKAlarms。 Now if I test with 2 todo entries like this: 现在,如果我用2个待办事项进行测试,如下所示:

  • todo test 1, due date 10:00 am 待办事项测试1,到期日上午10:00
  • todo test 2, due date 10:00 am 待办事项测试2,到期日上午10:00

I get 2 UserNotifications and 2 EKAlarm reminders in notification center at 10am. 上午10点,我在通知中心收到2个UserNotifications和2个EKAlarm提醒。 Now my Problem: 现在我的问题是:

  • If one of the EKAlarms is dismissed / acted upon, it disappears from notification center, while the other alarm stays there. 如果其中一个EKAlarms被撤消/采取了行动,则它将从通知中心消失,而另一个警报停留在该处。
  • If one of the UNUserNotifications is dismissed / acted upon, all other notifications disappear as well from notification center. 如果UNUserNotifications之一被驳回/采取了行动,则所有其他通知也会从通知中心消失

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 尝试检查有关iOS中通知的所有选项,尤其是特定于应用程序的通知
  • setting a unique external identifier as well as a unique UNNotificationCategory for each UserNotification, which had no effect - all notifications disappear regardless 为每个UserNotification设置一个唯一的外部标识符以及一个唯一的UNNotificationCategory,这无效-所有通知都会消失,无论
  • 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. 谷歌搜索是否有人遇到此问题,但我能找到的只是对旧版本iOS的抱怨,并没有立即消除所有通知。

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. 编辑: 这篇文章建议该问题专门与iOS 11有关。 I think it describes my problem well, but way shorter :) 我认为它很好地描述了我的问题,但更简短了:)

EDIT 2: This appears to be a problem with iOS 11.2.x. 编辑2:这似乎是iOS 11.2.x的问题。 This radar: https://openradar.appspot.com/36019616 exactly describes my problem. 这个雷达: https : //openradar.appspot.com/36019616准确地描述了我的问题。

EDIT 3: As of iOS 11.2.6, the behaviour hasn't changed. 编辑3:从iOS 11.2.6,该行为没有更改。

EDIT 4: No change of behaviour in iOS 11.3. 编辑4:在iOS 11.3中行为没有变化。

EDIT 5: No change in iOS 11.4. 编辑5:在iOS 11.4中没有更改。

EDIT 6: Finally! 编辑6:最后! The iOS12 update "stacks" notifications together. iOS12更新一起“堆叠”通知。 I can now handle every single alert/reminder the app is firing. 现在,我可以处理应用触发的每一个警报/提醒。

content.body添加一些文本:

content.body = 'Any text'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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