EDIT: I am setting exactly 365 local notifications UNUserNotification (one for each day a year). Button is calling at one time:
[self name1];
[self name2];
...
[self name365];
- one name for every day. If I try only eg. 3 days, it works perfectly. If I call all days (365x), it fires only the last local notification (365. only) - day 1-364 is missed (not fired). Any ideas?
Code:
-(void)Name1{
NSDateComponents *comps = [[NSDateComponents alloc] init];
comps.hour = 9;
comps.minute = 0;
comps.day = 23;
comps.month = 10;
UNMutableNotificationContent *objNotificationContent = [[UNMutableNotificationContent alloc] init];
objNotificationContent.title = [NSString localizedUserNotificationStringForKey:@"NAME" arguments:nil];
objNotificationContent.body = [NSString localizedUserNotificationStringForKey:@"text"
arguments:nil];
objNotificationContent.sound = [UNNotificationSound soundNamed:@"notif_bobicek.mp3"];
UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents: comps repeats:YES];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"requestNotificationForName1"
content:objNotificationContent trigger:trigger];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (!error) { NSLog(@"Local Notification succeeded"); }
else { NSLog(@"Local Notification failed"); }}];
}
.
-(void)Name2{ ... // same code
-(void)Name365{... // same code
Note: Identifier is different for each scheduled local notification.