安排 UILocalNotifications 每天或一周中的特定日期?

发布于 2024-11-27 06:07:02 字数 92 浏览 0 评论 0原文

我正在开发一个需要设置本地通知的警报项目,但问题是我需要在每个星期日或每个星期一重复它们,或者可能在星期日或星期一都重复它们, 任何人都可以帮我解决这个问题吗? 谢谢

I am working on an Alarm project which needs to set Local Notifications but the problem is that i need to repeat them on Every sunday or every monday or might be on both of sunday or monday ,
can Any one help me how to solve it,?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

UILocalNotification 有一个名为 repeatInterval 的属性。

但是,它仅指定您希望重复通知的时间间隔,具体取决于用户指定的 fireDate

假设火灾日期是星期一;如果像这样设置重复间隔,则

yourLocalNotif.repeatInterval =  kCFCalendarUnitWeekday; 

通知将在每个星期一发出。

现在,如果您想在星期一和星期日都有重复通知,则必须创建 2 个不同的本地通知对象,一个为星期一设置 fireDate,另一个为星期日设置 fireDate,并且两者都带有 repeatInterval<为 kCFCalendarUnitWeekday 设置的 /code> 属性。

UILocalNotification has a property called repeatInterval.

However, it only specifies the interval at which you want the notification to repeat, depending on the fireDate that your user specified.

Say, the fire date was on a monday; if the repeat interval was set like so,

yourLocalNotif.repeatInterval =  kCFCalendarUnitWeekday; 

the notification would go off every single monday.

Now, if you want to have repeating notifications for a monday and a sunday both, you would have to create 2 different Local Notification objects, one with a fireDate set for monday and another set for sunday, and both with the repeatInterval property set for kCFCalendarUnitWeekday.

白龙吟 2024-12-04 06:07:02

我猜重复就是问题所在。看看这个
我猜您知道您实例化了一个 UILocalNotification 对象,然后使用 UIApplication 方法 scheduleLocalNotification: 来安排它。正如您可以在文档,第四段文字。

i'm guessing that it is the repeating that is the problem. take a look at this.
and i guess you know that u instantiate a UILocalNotification object and then you schedule it using the UIApplication method scheduleLocalNotification:. as you can read in the documentation, 4th text passage.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文