每天在准确的时间安排通知

Schedule notification every day in exact time

我试图每天在准确的时间显示通知,但它有时会在一个小时内触发几次,或者根本不触发 0_o

let not = UILocalNotification()
not.soundName = UILocalNotificationDefaultSoundName
not.alertBody = "Time to stop drink!"
not.fireDate = Calendar.current.date(bySettingHour: HOUR, minute: MINUTE, second: 0, of: Date(), options: Calendar.Options())
not.repeatInterval = Calendar.Unit.day
UIApplication.shared().scheduleLocalNotification(not)

感谢@LeoDabus,我只添加了一行 not.timeZone = TimeZone.default 现在可以使用了