Swift,如何设置通知到每个月的前3天?

时间:2017-04-20 18:18:37

标签: ios swift notifications localnotification

我只是想问这是否可能? 我做了一个简单的方法,因为我怀疑每个月的第一天都会在12:00发出通知 我想做的是每个月的第1天,第2天,第3天发出通知。上午8:00和12:00

func scheduleLocalNotification() {
    let calendar = NSCalendar.autoupdatingCurrent
    var calendarComponents = DateComponents()

    calendarComponents.day = 1
    calendarComponents.hour = 12
    calendarComponents.minute = 00

    let trigger = UNCalendarNotificationTrigger(dateMatching: calendarComponents, repeats: true)


    let localNotification = UILocalNotification()

    localNotification.alertBody = "Hey, you must go shopping, remember?"
    localNotification.soundName = UILocalNotificationDefaultSoundName
}

0 个答案:

没有答案