1

The old (pre IOS10.0) API for notifications had a property for timezone so that the notification would adjust to time zones.

The new API UNNotifications does not seem to have a time zone property.

Does this mean, you are just supposed to ignore time zones? Or how would you reproduce the same behavior that was in the old LocalNotifications when you set a time zone.

//New

NSDate *now = [NSDate date];

UNMutableNotificationContent *content = [UNMutableNotificationContent new];
            content.title = [NSString localizedUserNotificationStringForKey:@"myalert" arguments:nil];
            NSDateComponents *triggerDate = [[NSCalendar currentCalendar]
                                                         components:NSCalendarUnitYear +
                                                         NSCalendarUnitMonth + NSCalendarUnitDay +
                                                         NSCalendarUnitHour + NSCalendarUnitMinute +
                                                         NSCalendarUnitSecond fromDate:timeOfDate];
            UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:triggerDate
                                                                                                                          repeats:NO];

UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"myalert" content:content trigger:trigger];


    //Old:

     reminderNotification = [[UILocalNotification alloc] init];
     reminderNotification.fireDate = myDate;
     reminderNotification.timeZone = [NSTimeZone defaultTimeZone];
     reminderNotification.alertAction = @"Meeting begins";
user6631314
  • 1,751
  • 1
  • 13
  • 44
  • 1
    https://stackoverflow.com/questions/47327446/notification-center-and-changing-timezones?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa ? – Larme Apr 19 '18 at 16:02
  • Bingo. That did it. Thanks. – user6631314 Apr 19 '18 at 18:00
  • Possible duplicate of [Notification Center and changing timezones](https://stackoverflow.com/questions/47327446/notification-center-and-changing-timezones) – Larme Apr 20 '18 at 09:20

0 Answers0