【发布时间】:2014-08-27 16:58:30
【问题描述】:
我的应用中有这个方法可以触发预定的本地通知:
- (void)scheduleNotificationForTime:(long long)atTime
{
NSDate *fireDate = [DatesMngr getDateFromLongLong:atTime];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = fireDate;
localNotif.timeZone = [NSTimeZone localTimeZone];
localNotif.alertBody = @"Active Status";
localNotif.alertAction = @"View Details";
localNotif.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] cancelAllLocalNotifications];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
如果用户没有在她的设备设置中更改她的时区,它工作正常,但如果她在已经安排但尚未启动后更改时区,则不会启动通知。我也尝试过[NSTimeZone defaultTimeZone],但没有成功。有什么方法可以检测到这些时区更改并刷新fireDate 以获取已安排的本地通知?
谢谢
【问题讨论】:
标签: ios timezone scheduled-tasks uilocalnotification