swift - 如何快速发出两个月的循环通知?

标签 swift loops scheduling uilocalnotification

我想发送两个月的本地和日程通知,一天三次。

我已经设置了用户注册后的第一条通知,虽然我不知道应该如何继续。

    dateComps.day = registrationDate.day
    dateComps.month = registrationDate.month
    dateComps.year = registrationDate.year
    dateComps.hour = 7
    dateComps.minute = 0

    let itemDate = calendar.dateFromComponents(dateComps)

    localNotif.fireDate = itemDate!.dateByAddingTimeInterval(24*60*60)
    localNotif.timeZone = NSTimeZone.defaultTimeZone()

    localNotif.alertBody = "Good Morning new user!"
    localNotif.alertAction = "View details"
    localNotif.alertTitle = "Good morning"

最佳答案

一个应用最多可以提前设置64条本地通知,所以实际上一天3条通知只能提前21天设置。

你能做的最好的事情就是每次应用程序打开调用时: UIApplication.sharedApplication().scheduledLocalNotifications 并检查 fireDate 属性并根据需要安排更多通知。

关于swift - 如何快速发出两个月的循环通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36280793/

相关文章:

hadoop - 在 Hadoop 中并行加载和处理数据

python - Pygame - 我可以让音乐有一个介绍然后是一个循环点吗?

Linux内核调度

linux-kernel - rcu_preempt self 检测到 CPU { 0} 上的停顿

swift - Vapor:处理 HTTPS 请求?

javascript - useInterval 和 React hooks 的问题 - 无限循环

objective-c - 如何循环 iOS UILabel 以显示博客文章的多条评论?

ios - 单击表格 View 单元格行时如何推送新的 View Controller ?

swift - 仅接收来自过滤器的一项数据以构造

swift - 如何处理转义键按下事件?