我正在尝试创建由静态时差分隔的4种不同的本地通知。意思是,第一个通知将在开始时间触发,然后每X秒触发另一个本地通知(总共4个)。
仅创建2个本地通知的问题而不是4。我不明白为什么。
double timeToAdd=0;
double timeDifference=[album.end_time timeIntervalSinceDate:album.start_time]/4;
for (int i = 1; i <= 4; i++)
{
NSDate *dateToNotify = [NSDate dateWithTimeInterval:timeToAdd sinceDate:album.start_time];
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = dateToNotify;
localNotification.alertBody = @"Click to sync";
localNotification.alertAction=@"Click to sync";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.userInfo =@{@"id":[ album.id stringByAppendingString:album.code]};
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
timeToAdd+=timeDifference;
}