wip: add proper fire date

parent 694d6345
...@@ -700,13 +700,26 @@ ...@@ -700,13 +700,26 @@
arguments:nil]; arguments:nil];
content.sound = [UNNotificationSound defaultSound]; content.sound = [UNNotificationSound defaultSound];
/// 4. update application icon badge numberß NSDate *fireDate = notification.fireDate;
//content.badge = @([[UIApplication sharedApplication] applicationIconBadgeNumber] + 1);
// Deliver the notification in five seconds. NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger
triggerWithTimeInterval:1.f repeats:NO]; // Extract all date components into dateComponents
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"FiveSecond" NSDateComponents *dateComponents = [gregorianCalendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit
content:content trigger:trigger]; fromDate:fireDate];
/// 4. update application icon badge number
content.badge = @([[UIApplication sharedApplication] applicationIconBadgeNumber] + 1);
// Deliver the notification at the fire date.
UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:NO];
NSString *identifier = @"DefaultNotificationIdentifier";
if(notification.userInfo!=nil && [notification.userInfo objectForKey:@"id"]!=nil) {
identifier = [notification.userInfo objectForKey:@"id"];
}
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger];
/// 3. schedule localNotification /// 3. schedule localNotification
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment