0
我想做點什麼。我的通知設置爲11和12小時。我想取消訂閱這些通知只需幾個小時11.我該怎麼做?如何取消通知?
我的代碼;
NSCalendar *greg = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents * component = [greg components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit fromDate:[NSDate date]];
[component setYear:2013];
[component setMonth:m];
[component setDay:d];
[component setHour:x];
[component setMinute:y];
UIDatePicker *dd = [[UIDatePicker alloc]init];
[dd setDate:[greg dateFromComponents:component]];
UILocalNotification * bildirim = [[UILocalNotification alloc]init];
[bildirim setAlertBody:newtask.name];
[bildirim setFireDate:dd.date];
bildirim.soundName = UILocalNotificationDefaultSoundName;
bildirim.alertAction = NSLocalizedString(@"Test", nil);
//[bildirim setFireDate:[NSDate dateWithTimeIntervalSinceNow:0]];
[bildirim setTimeZone:[NSTimeZone defaultTimeZone]];
[[UIApplication sharedApplication] scheduleLocalNotification:bildirim];
我找到了一個代碼。不幸的是這段代碼正在刪除所有通知
[[UIApplication sharedApplication] cancelAllLocalNotifications];
對不起,我的英語不好。
試圖:http://pastie.org/7675392 錯誤:使用未聲明的標識符'eventID'。 什麼是eventID? :S – Salieh 2013-04-20 18:42:43
你不能讓這段代碼運行,你需要定義你自己的'UniqueID/EventID' ..並使用這個ID你可以跟蹤你想取消哪個通知.. – iphonic 2013-04-20 18:57:18