我想在每个星期一发送本地通知 . 假设我有一个场景,我必须在每个星期一发送药物提醒一个月 . 所以一个月内会有4个通知 . 我的代码如下,但我无法弄清楚以下事项; 1)如何在特定日期发送通知2)如何限制最大结束日期的通知 .
发送通知的代码如下;
let notification = UILocalNotification()
notification.alertBody = "Take Medication" notification.alertAction = "open" // text that is displayed after "slide to..." on the lock screen - defaults to "slide to view"
notification.fireDate = NSDate()
notification.userInfo = ["title": "notification app", "UUID": "Some Unique Guid"]
UIApplication.sharedApplication().scheduleLocalNotification(notification)
有人可以帮忙吗?此致,neena
2 回答
将NSWeekCalendarUnit添加到NSDateComponents并将repeatInterval设置为NSWeekCalendarUnit . 例如 :
你可以管理类似的东西,