取消UILocalNotification [英] Cancel UILocalNotification
问题描述
我的UILocalNotification有问题。
I have a problem with my UILocalNotification.
我使用我的方法安排通知。
I am scheduling the notification with my method.
- (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];
}
它的工作正常,我正在收到通知。问题是我应该取消通知。 Im使用这种方法。
Its work fine and I'm correctly receiving the notification. The problem is when I should cancel the notification. Im using this method.
- (void) deleteNewNoteLocalReminder:(NSString*) reminderID noteIDe:(NSInteger)noteIDE{
[[UIApplication sharedApplication] cancelLocalNotification:(UILocalNotification *)notification ????
}
我不知道该怎么做, :
Im not sure what to do here, but my questions are:
如何知道我应该删除哪个UILocalNotification对象?
是否有方法可以列出所有通知?
How do I know which UILocalNotification object I should delete?
Is there a way to list all notifications?
我唯一要做的就是删除提醒的ID。
我正在考虑将UILocalNotification对象保存在我的Note 对象,并得到它的方式,当我保存到我的SQLite数据库序列化对象等等...有一个更聪明的方式吗?
The only thing I have is the ID of which reminder I should delete.
I was thinking about to save the UILocalNotification object in my "Note" object and get it that way, and when I saving to my SQLite database serialize the object and so on ... is there a smarter way?
推荐答案
您可以从 scheduledLocalNotifications ,或者您可以取消全部: / p>
You can get a list of all scheduled notifications from scheduledLocalNotifications or you can cancel them all:
[[UIApplication sharedApplication] cancelAllLocalNotifications];
这篇关于取消UILocalNotification的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!