I am working on the reminder app. For eg. if I set the timings of 05:25 scheduling it to repeat at every 2 hours, it is reminded at the interval of every 2 hours but it doesn’t remind at the current time i.e. 05:25.
UNMutableNotificationContent *localNotification = [UNMutableNotificationContent new];
localNotification.title = [NSString localizedUserNotificationStringForKey:@"Reminder!" arguments:nil];
localNotification.body = [NSString localizedUserNotificationStringForKey:_getReminderName arguments:nil];
localNotification.sound = [UNNotificationSound defaultSound];
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:60*60*2 repeats:YES];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:_getReminderName content:localNotification trigger:trigger];
request = [UNNotificationRequest requestWithIdentifier:_getReminderName content:localNotification trigger:trigger];
/// 3. schedule localNotification
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (!error) {
NSLog(@"add NotificationRequest succeeded!");
}
}];