我想知道是否有办法从先前设置的本地通知中获取剩余时间。iPhone - 从UILocalNotification获取剩余时间
比方说,我做这样的事情:
//Creating Notification
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = someTime;
localNotif.alertBody = @"Your parking time will expire in 10 mins";
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
于是我完全关闭我的应用程序。我重新打开它,我想显示一些消息,说明通知启动需要多长时间。
在此先感谢。
因此,如果我使用scheduledLocalNotifications检索我的通知,我可以得到它将触发的时间? – Chompas 2011-05-03 20:45:23
Docs说它应该返回一个UILocalNotifications数组。该类具有fireDate属性,其中包含“系统应发送通知的日期和时间”。从中减去当前时间应该告诉你剩下的时间。 – DavidN 2011-05-03 20:58:24