只是让它们具有“日期”,“isCanceled”字段和唯一id“alarmId”列(无论你想使用REST)的数据库表。因此,当用户想要取消报警试试这个,
NSString *alarmId = @"some_id_to_cancel";
UILocalNotification *notificationToCancel=nil;
for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications]) {
if([aNotif.userInfo objectForKey:@"ID"] isEqualToString:alarmId]) {
notificationToCancel = aNotif;
break;
}
}
[[UIApplication sharedApplication] cancelLocalNotification:notificationToCancel];
使用这个更好的,你创建你的报警,
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;
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:stringID forKey:@"ID"];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];