从 iOS 11.2 开始,从我的应用程序中清除单个通知似乎将它们全部清除。由于没有更改任何代码,我似乎无法弄清楚发生了什么。
我UNNotificationRequest
是使用 GUID 创建的,具有普遍唯一性(因为我的应用程序允许用户基于相同的提醒类型创建多个警报)。
我一定做错了什么?
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];