我試圖在每個星期一發送本地通知。假設我有一個場景,在這個場景中,我必須在每個星期一發送藥物提醒一個月。因此,一個月內將發出總共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
你可能會想安排多個通知,一個是要每一個具體的日期。 – Paulw11
修復週一發佈的任何日期,然後將timeInterval設置爲每週。 notification.repeatInterval = NSWeekCalendarUnit; –