我想知道是否有辦法從先前設置的本地通知中獲取剩餘時間。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