【发布时间】:2010-07-01 13:32:44
【问题描述】:
我的 UILocalNotification 有问题。
我正在用我的方法安排通知。
- (void) sendNewNoteLocalReminder:(NSDate *)date alrt:(NSString *)title
{
// some code ...
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = itemDate;
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertAction = NSLocalizedString(@"View Details", nil);
localNotif.alertBody = title;
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 0;
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:stringID forKey:@"id"];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
}
它工作正常,我正确地收到了通知。问题是我什么时候应该取消通知。我正在使用这种方法。
- (void) deleteNewNoteLocalReminder:(NSString*) reminderID noteIDe:(NSInteger)noteIDE
{
[[UIApplication sharedApplication] cancelLocalNotification:(UILocalNotification *)notification ????
}
我不确定在这里做什么,但我的问题是:
我如何知道我应该删除哪个 UILocalNotification 对象?
有没有办法列出所有通知?
我唯一拥有的是我应该删除的提醒的 ID。
我正在考虑将 UILocalNotification 对象保存在我的“Note”对象中并以这种方式获取它,当我保存到我的 SQLite 数据库时序列化对象等等......有没有更聪明的方法?
【问题讨论】:
标签: iphone cocoa-touch notifications ios4