My app schedules multiple UNNotificationRequest for future times. Each request has a unique identifier. This is not the case of having a repeat on a UNCalanderNotificationTrigger, since repeat is set to NO. Rather, each request is set for a different future calendar date, but they are all requested serially and at essentially the same time. Each trigger is set by the interval (NSTimeInterval) that is passed in to the following method. None of the requests are subsequently received in the UNNotificationCenter delegate (appDelegate), either when the app is in the background or in the foreground. None of Apple's Developer documentation has a relevant example. I am wondering if I should be checking for completion in a completion handler (my code has withCompletionHandler: nil, but that is what is shown in Apple's examples).
-(UNNotificationRequest *)triggerNotifications: (NSString *)identifier : (NSTimeInterval) interval{
// Note: identifier must be unique or else each new request causes all others to be cancelled.
NSLog(@"interval: %f", interval);
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init];
content.title = NSLocalizedString(@"Timer expired", nil);
content.body = NSLocalizedString(@"Touch to continue", nil);
content.sound = [UNNotificationSound defaultSound];
content.categoryIdentifier = @"com.nelsoncapes.localNotification";
// NSDate *today = [NSDate date];
// NSDate *fireDate = [today dateByAddingTimeInterval:interval];
NSDate *fireDate = [NSDate dateWithTimeIntervalSinceNow:interval];
// first extract the various components of the date
NSCalendar *calendar = [NSCalendar currentCalendar];
NSInteger hour = [calendar component:NSCalendarUnitHour fromDate:fireDate];
NSInteger minute = [calendar component:NSCalendarUnitMinute fromDate:fireDate];
NSInteger second = [calendar component:NSCalendarUnitSecond fromDate:fireDate];
//then make new NSDateComponents to pass to the trigger
NSDateComponents *components = [[NSDateComponents alloc]init];
components.hour = hour;
components.minute = minute;
// components.second = second;
// construct a calendarnotification trigger and add it to the system
UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:NO];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier: identifier content:content trigger:trigger];
NSLog(@"request: %@", request);
[center addNotificationRequest:request withCompletionHandler:nil];
return request;