1
我已經安排每日通知,與此代碼:UILocalNotification計劃每天直到日期
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setDay:7];
[components setMonth:3];
[components setYear:2014];
[components setHour:9];
NSInteger minute = arc4random() % 59;
[components setMinute:minute];
[components setSecond:0];
[calendar setTimeZone:[NSTimeZone defaultTimeZone]];
NSDate *dateToFire = [calendar dateFromComponents:components];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.userInfo = @{@"uid": DailyNotificationUid};
localNotification.fireDate= dateToFire;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
NSString *body = NSLocalizedString(@"Local Notification Alert Body", nil);
localNotification.alertBody = body;
localNotification.alertAction = NSLocalizedString(@"Local Notification Alert Action", nil);
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
localNotification.repeatInterval = NSCalendarUnitDay;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
但我錯過到期日期。通知應在聖誕節結束,而用戶不必啓動應用程序。這可能嗎?
可能重複的問題,你可以臉頰這個帖子[http://stackoverflow.com/questions/6340664/delete-a-particular-local-notification][1] [1]:HTTP:/ /stackoverflow.com/questions/6340664/delete-a-particular-local-notification – 2014-08-27 11:35:00
你怎麼做? – iphonemaclover 2014-12-21 08:32:08