let dateComponents1 = calendar!.components([NSCalendarUnit.Day, NSCalendarUnit.WeekOfMonth, NSCalendarUnit.Month,NSCalendarUnit.Year,NSCalendarUnit.Hour,NSCalendarUnit.Minute], fromDate:date)
dateComponents1.month = 5
dateComponents1.day = 12
dateComponents1.hour = 20
dateComponents1.minute = 00
let notification1 = UILocalNotification()
notification1.alertAction = "notification1"
notification1.alertBody = "notification1"
notification1.repeatInterval = NSCalendarUnit.WeekOfYear
notification1.fireDate = calendar!.dateFromComponents(dateComponents1)
UIApplication.sharedApplication().scheduleLocalNotification(notification1)
let dateComponents2 = calendar!.components([NSCalendarUnit.Day, NSCalendarUnit.WeekOfMonth, NSCalendarUnit.Month,NSCalendarUnit.Year,NSCalendarUnit.Hour,NSCalendarUnit.Minute], fromDate:date)
dateComponents2.month = 5
dateComponents2.day = 13
dateComponents2.hour = 14
dateComponents2.minute = 00
let notification2 = UILocalNotification()
notification2.alertAction = "notification2"
notification2.alertBody = "notification2"
notification2.repeatInterval = NSCalendarUnit.WeekOfYear
notification2.fireDate = calendar!.dateFromComponents(dateComponents2)
UIApplication.sharedApplication().scheduleLocalNotification(notification2)
我想在每週的特定時間發出2個通知。這是我如何實施通知。每週星期四和星期五下午8點發出2個通知。我做對了嗎?有時我會在火災時收到重複通知。迅速多個通知
你在哪裏調用這段代碼?你在打didFinishLaunching嗎? – Harish
我從didBecomeActive –