0
私のコードに問題があります。すぐに週刊ローカル通知を設定する方法
xcode7にローカル通知を設定したいのですが、私はあなたの大学のコースを配置できるカレンダーを開発していますが、私はjsonデータベースからスケジュールを取得しています。クラスが始まりますが、私のコードがなぜ機能していないのかわかりません。
これは、毎週月曜日の13:40に通知を繰り返す場合の例です。
曜日と時間のみ設定できますか?または月と年を指定する必要がありますか?
var dateComp:NSDateComponents = NSDateComponents()
dateComp.day = 01;
dateComp.hour = 13;
dateComp.minute = 40;
dateComp.timeZone = NSTimeZone.systemTimeZone()
var calender:NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)!
var date:NSDate = calender.dateFromComponents(dateComp)!
let notification = UILocalNotification()
notification.fireDate = date
notification.alertBody = "Swipe to unlock"
notification.alertAction = "You've got a class soon!"
notification.soundName = UILocalNotificationDefaultSoundName
notification.userInfo = ["CustomField1": "w00t"]
notification.repeatInterval = NSCalendarUnit.WeekOfYear
UIApplication.sharedApplication().scheduleLocalNotification(notification)
ローカル –
http://stackoverflow.com/a/34575836/2303865にご通知タイムゾーンを設定する必要があります –