2013-02-17 2 views
1
- (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년에서 2013년까지/월/01 일 통지/수도/01

답변

0

아니, 그것은 것 화재 날짜부터 시작하여 매일 취소 알림을 예약합니다 (취소 할 때까지).

날짜 범위를 예약하고 한 번에 설정할 수있는 로컬 알림의 한도를 초과하지 않는 경우 (64 세가 필요하지만 2 개월 미만인 경우), 나는 최선이라고 생각합니다. 매일 현지 알림을 하나씩 예약하십시오.

시작 날짜에 대해 NSDate 개체로 시작하고 반복 간격없이 로컬 알림을 예약 한 다음 NSDate를 하루 늘린 다음 범위 끝 날짜에 도달 할 때까지 로컬 알림 일정을 반복합니다.

관련 문제