0

毎日起動するアプリケーションのロケール通知を作成しました。Apple 開発者のドキュメントにも、64 個の通知しか起動できないと記載されています。1 年ごとに毎日発生するようにスケジュールされた通知を意味するので、通知をキャンセルして、スケジュールされた計画で再び発生させる正しい方法はありますか?

- (void)cancelLocalNotification:(UILocalNotification *)notification {

[[UIApplication sharedApplication] cancelLocalNotification:notification;

}

ここに私の通知コードがあります:

- (void) notification  {


    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSPersianCalendar];
    NSDate *now = [NSDate date];    
    NSDateComponents *componentsForFireDate = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit| NSSecondCalendarUnit ) fromDate: now];

    [componentsForFireDate year];
    [componentsForFireDate month];
    [componentsForFireDate day];
    [componentsForFireDate setHour:1];
    [componentsForFireDate setMinute:2];
    [componentsForFireDate setSecond:1];

    NSDate *fireDateOfNotification = [calendar dateFromComponents: componentsForFireDate];

    UILocalNotification *notification = [[UILocalNotification alloc]init];
    notification.fireDate = fireDateOfNotification;
    notification.timeZone = [NSTimeZone localTimeZone]; 
    notification.repeatInterval= NSDayCalendarUnit; 


    notification.alertAction = @"View";
    notification.soundName = UILocalNotificationDefaultSoundName;

        [[UIApplication sharedApplication] scheduleLocalNotification:notification];

}
4

1 に答える 1

0

ここであなたの問題を読んでください。それは確かにあなたの問題を解決しましたiOSローカル通知を繰り返す

NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
        NSDate *pickerDate = [self.datePicker date];
        NSDateComponents *dateComponents = [calendar components:( NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit )
                                                       fromDate:pickerDate];
        NSDateComponents *timeComponents = [calendar components:( NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit )
                                                       fromDate:pickerDate];
        NSDateComponents *dateComps = [[NSDateComponents alloc] init];
        [dateComps setDay:[dateComponents day]];
        [dateComps setMonth:[dateComponents month]];
        [dateComps setYear:[dateComponents year]];
        [dateComps setHour:[timeComponents hour]];
        [dateComps setMinute:[timeComponents minute]];
        [dateComps setSecond:[timeComponents second]];
        NSDate *itemDate = [calendar dateFromComponents:dateComps];

        UILocalNotification *localNotif = [[UILocalNotification alloc] init];
        if (localNotif == nil)
            return;
        localNotif.fireDate = itemDate;
        localNotif.timeZone = [NSTimeZone defaultTimeZone];
        localNotif.alertBody = [eventText text];
        localNotif.alertAction = @"View";
        localNotif.soundName = audios;
        localNotif.applicationIconBadgeNumber = 1;

        [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
        [localNotif release];
于 2012-04-17T06:38:38.490 に答える