I know that there are several questions here and there about how to delete a local notification, which can be either an entire or a specific notification. I also looked through the link of the local notification class and found some methods, such as retry time, fire date, body warning, time zone, etc., but I can not find out any information on how to change the fire date, which is already has been installed. If the user sets a notification with the date today and the time 16:50, but if the user wants to change the set date / time, then what happens in the notification works in both cases. This is a mistake regarding programming ethics!
In fact, I want the previous notification to be canceled, that is, the date must be changed to edit it, and the notification must be set and run on the new date.
Here is how I set up the notification, sample code:
- (void)setNotification
{
Class cls = NSClassFromString(@"UILocalNotification");
reminderNotification = [[cls alloc] init];
if (cls != nil)
{
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc]init]autorelease];
[dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSDate *notificationDate = [dateFormat dateFromString:textField2.text];
reminderNotification.fireDate = notificationDate;
reminderNotification.timeZone = [NSTimeZone defaultTimeZone];
NSString *reminderText = [NSString stringWithFormat:@"%@ %@ on %@",textField.text,textField1.text,strDate];
reminderNotification.alertBody = reminderText;
reminderNotification.alertAction = @"View";
reminderNotification.soundName = @"lazy_afternoon.mp3";
reminderNotification.applicationIconBadgeNumber = 1;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:self.textField1.text forKey:kReminder];
reminderNotification.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:reminderNotification];
[reminderNotification release];
}
}
Can anyone direct me on the right path, how to cope with this task.
Thanks to everyone in advance :)
source
share