多个UILocalNotification计划不起作用

时间:2013-01-22 23:38:01

标签: iphone ios ipad scheduled-tasks uilocalnotification

我需要安排一些日期,例如每周特定的警报,但只显示最后一个预定的通知。

- (void)scheduleNotificationForDate:(NSDate*)date {
    [[UIApplication sharedApplication] cancelAllLocalNotifications];
    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
    localNotification.fireDate = date;
    NSLog(@"Notificação agendada: %@",localNotification.fireDate);
    localNotification.repeatInterval = NSWeekdayCalendarUnit;
    [localNotification setHasAction:YES];
    localNotification.timeZone = [NSTimeZone localTimeZone];
    localNotification.alertBody = @"Bom dia!";
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSString *nome = [[[userDefaults objectForKey:@"soundName"] componentsSeparatedByString:@"."] lastObject];
    localNotification.soundName = [NSString stringWithFormat:@"%@.caf",nome];
    localNotification.applicationIconBadgeNumber = -1;   
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
    [localNotification release];

}

我用不同的日期调用此方法一次,并且通知只能通过参数的最后日期完美地工作。

我不知道如何解决这个问题,谢谢!

对不起英文:/

0 个答案:

没有答案