管理您的应用已安排的本地通知的好方法是什么?

时间:2010-08-09 17:43:43

标签: ios iphone ipad cocoa-touch localnotification

我正在深入研究iOS开发,并且一直在研究闹钟应用程序以熟悉iOS平台和SDK。我正在使用本地通知来处理我的警报,但我需要一些管理我设置的本地通知的方法,以便在我编辑或删除与它们相关的任何警报时可以更新它们。我想出了如何在计划后使用cancelLocalNotification:函数取消计划本地通知,但是我很难弄清楚如何检索与已编辑或删除的警报关联的本地通知对象,以便我可以使用该功能。我应该注意,用于创建本地通知的所有报警对象都存储在Core Data DB中,其界面定义为...

@interface Alarm :  NSManagedObject  
{
}

@property (nonatomic, retain) NSNumber * Snooze;
@property (nonatomic, retain) NSNumber * AlarmID;
@property (nonatomic, retain) NSString * Label;
@property (nonatomic, retain) NSDate * Repeat;
@property (nonatomic, retain) NSDate * Time;
@property (nonatomic, retain) NSNumber * Enabled;
@property (nonatomic, retain) NSString * Song;
@property (nonatomic, retain) NSString * Sound;

@end
  1. 管理我的应用安排的本地通知的好方法是什么,以便我以后可以检索那些本地通知对象并在需要时重新安排它们?
  2. 有没有办法检索您的应用已安排的本地通知?
  3. 如果是这样,有没有办法独特地识别它们?
  4. 非常感谢您的帮助!

2 个答案:

答案 0 :(得分:16)

要回答问题#2,请使用scheduledLocalNotifications,这将向您回复为您的应用安排的所有通知的NSArray。

要回答问题#3,请使用userInfo类的UILocalNotification属性。这是一本字典,你可以保存你想要的任何东西。

答案 1 :(得分:0)

  1. 您可以使用UIApplication类的scheduledLocalNotifications方法检索应用已安排的所有本地通知。