すべてまたは特定の通知である可能性のあるローカル通知を削除する方法に関して、あちこちにいくつかの質問があることを私は知っています。また、ローカル通知クラスの参照を調べて、繰り返し時間間隔、発火日、アラートボディ、タイムゾーンなどのいくつかのメソッドを見つけました...しかし、発火日を変更する方法に関するある種の情報を見つけることができません。すでに設定されています。ユーザーが今日の日付と午後4時50分に通知を設定したが、ユーザーが設定された日付/時刻を変更したい場合は、両方の場合に通知が発生します。プログラミング倫理に関する限り、これは失敗です!
実際に私が欲しいのは、以前の通知をキャンセルする必要があります。つまり、日付を変更して編集し、通知を設定して新しい日付に配信する必要があります。
これは私が通知、サンプルコードを設定する方法です:
- (void)setNotification
{
//Set notification after confirmation of saved data
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:@"%@ 's %@ 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];
}
}
このタスクに対処する方法は?