我正在尝试在我的代码中嵌入本地通知,我希望每 15 分钟后重复一次。它需要 NsCalendarUnit,但我无法弄清楚如何将 15 薄荷糖转换为 NSCalendarUnit
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:30];
localNotification.repeatInterval = 900.0;
localNotification.alertBody = @"Your alert message";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
最佳答案
repeatInterval
不是时间,它的值是 NSCalendarUnit
.
这意味着您可以不将间隔设置为 15 分钟。
您最好的选择是使用 4 个通知,repeatInterval
为 NSCalendarUnitHour
并将它们设置为间隔 15 分钟。
关于ios - 本地通知 15 分钟间隔问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41243920/