- (void) scheduleGeneralNotificationFrequentlyWithItem:(ToDoItem *)item interval:(int)minutesBefore frequent:(NSCalendarUnit)frequentUnit{
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
[dateComps setDay:item.day];
[dateComps setMonth:item.month];
[dateComps setYear:item.year];
[dateComps setHour:item.hour];
[dateComps setMinute:item.minute];
NSDate *itemDate = [calendar dateFromComponents:dateComps];
[dateComps release];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate = [itemDate dateByAddingTimeInterval:-(minutesBefore*60)];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
if (!item.eventName) {
item.eventName = @"My event name";
}
localNotif.alertBody = item.alertBody;
localNotif.alertAction = NSLocalizedString(@"Details", nil);
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
localNotif.userInfo = item.data; // some data
localNotif.repeatInterval = frequentUnit; // here I put NSDayCalendarUnit
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
NSString *isDisableLocalPush = [Settings getSetting:kPraktijDisableLocalPushKey];
if ([isDisableLocalPush isEqualToString:kJSONValueYes]) { //disable all notifications after added it
[self disableAllLocationPushNotifications];
}
}
上記のコードでは、 localNotif.fireDate まで毎日スケジュールされますよね?
私が達成しようとしているのは、次の月から別の月までの毎日のスケジュール通知です例:2013/march/01から2013/may/01の毎日の通知