UILocalNotification 每个工作日重复一次(节假日除外)
我正在开发一款 iPhone 应用程序,该应用程序需要在每个工作日的给定时间显示通知。我通过调度一个 UILocalNotification 来完成此任务,该 UILocalNotification 的重复间隔属性设置为 kCFCalendarUnitWeekday。
问题是警报不应该在假期出现。我的应用程序的配置文件中维护着 10 个假期的列表。有没有办法阻止这些天显示通知?当应用程序在前台或后台运行时,最好是在关闭时,应显示此通知,尽管我认为我可以接受在应用程序关闭时不显示它。
I'm working on an iPhone app that requires a notification be presented at a given time every weekday. I've accomplished this by scheduling a UILocalNotification whose repeatInterval property is set to kCFCalendarUnitWeekday.
The problem is that the alert shouldn't be presented on holidays. I have a list of 10 holidays maintained in a configuration file in my app. Is there a way to prevent the notification from being shown on these days? This notification should be presented when the app is running in the foreground or background, and preferably when it is closed, although I think that I could accept it not being shown when the app is closed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从这篇文章中复制了这个答案: https://stackoverflow.com/posts/7257168/edit 但记住了这一点问题。它也回答了您的问题
正如您从
repeatInterval
属性中看到的,您只能指定预定义的日历单位。因此,如果您希望通知在上述任何时间间隔内重复,您可以将 repeatInterval 属性与这些值中的任何一个一起使用。但是,如果您希望通知以“每两天”等间隔或不规则的间隔重复,那么您必须为每个提醒创建单独的通知。
I've copied this answer from this post: https://stackoverflow.com/posts/7257168/edit but remembered this question. It answers your question too
As you can see from the
repeatInterval
property, that you can specify only the predefined calendar units.So, if you want the notification to repeat on any of these above intervals you can use the repeatInterval property with any of these values. But if you want the notification to repeat on intervals some like "Every Two Days" or on some irregular intervals, then you have to create individual notifications for each of those reminders.