从iOS 11.2开始,从我的应用程序中清除单个通知似乎可以清除所有通知。我似乎无法弄清楚发生了什么,因为没有更改代码。
我的UNNotificationRequest
是使用 GUIID 创建的,具有普遍唯一性(因为我的应用允许用户基于相同的提醒类型创建多个警报(。
我一定做错了什么?
UNMutableNotificationContent *alertContent = [[UNMutableNotificationContent alloc] init];
alertContent.categoryIdentifier = ALERT_CATEGORY_ALERTS;
alertContent.body = task.title;
alertContent.userInfo = ... a dictionary of stuff
...
NSDateComponents *dateCompos = [localGregCal components:NSCalendarUnitYear | NSCalendarUnitMonth
| NSCalendarUnitDay | NSCalendarUnitHour |
NSCalendarUnitMinute | NSCalendarUnitSecond fromDate:deliveryDate];
UNCalendarNotificationTrigger *alertTrigger = [UNCalendarNotificationTrigger
triggerWithDateMatchingComponents:dateCompos repeats:NO];
UNNotificationRequest *notifRequest = [UNNotificationRequest requestWithIdentifier:NEW_GUUID
content:alertContent trigger:alertTrigger];
iOS 11.2.0-.5问题:
rdar://36575570:iOS 11.2.2:清除/对通知原因的操作...
我也只在 iOS 11.2 上遇到同样的问题,现在我已经将我的操作系统 11.2 更新到 11.3。现在它对我来说工作正常。
因此,这是在iOS 11.3中解决的与操作系统相关的错误。
另一个原因/解决方案:
如果在无alert
静默通知到达时清除单个通知,请确保aps.batch
未设置为 0。确保aps.batch
完全不包含在您的消息中。