ios - 本地通知 15 分钟间隔问题

标签 ios objective-c notifications

我正在尝试在我的代码中嵌入本地通知,我希望每 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 个通知,repeatIntervalNSCalendarUnitHour 并将它们设置为间隔 15 分钟。

关于ios - 本地通知 15 分钟间隔问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41243920/

相关文章:

html - 解析 JSON 中的 <img src> 标签 - iOS

objective-c - 如何从 Objective-C 登录电子邮件提供商?

ios - 使用 Objective-C 下载 AWS S3 文件成功然后不成功

ios - 如何在 Swift beta 3 中从 UIImagePickerControllerDelegate 获取 UIImage?

ios - 何时何地获取 Watch Complication 的数据

javascript - Web 应用程序中的状态栏通知

android - 如何知道Android Notification大图样式中的图片大小?

iphone - 应用未运行时检查 JSON 内容的变化

ios - 创建嵌套 TableView 或单独的页面?

ios - 从一个 Storyboard转到另一个 Storyboard?