swift
1func applicationDidEnterBackground(application: UIApplication) { 2 // push設定 3 // 登録済みのスケジュールをすべてリセット 4 application.cancelAllLocalNotifications() 5 6 let notification = UILocalNotification() 7 notification.alertAction = "アプリに戻る" 8 notification.alertBody = noticeDic["lessonMg"] as? String 9 notification.timeZone = NSTimeZone.defaultTimeZone(); 10 let now = NSDate() 11 print(now) 12 let calendar = NSCalendar(identifier: NSCalendarIdentifierGregorian) 13 let comps:NSDateComponents = calendar!.components([NSCalendarUnit.Hour, .Minute, .Second], fromDate: now) 14 comps.calendar = calendar 15 comps.hour = 4 16 comps.minute = 30 17 18 let now2 = comps.date; 19 print(now2) 20 21 notification.fireDate = now2 22 23 notification.soundName = UILocalNotificationDefaultSoundName 24 // アイコンバッジに1を表示 25 notification.applicationIconBadgeNumber = 1 26 // あとのためにIdを割り振っておく 27 notification.userInfo = ["notifyId": "ranking_update"] 28 application.scheduleLocalNotification(notification) 29 }
上記のようなコードでノーカル通知を設定し、実行してからホームに戻ると、すぐに通知が送られてきます。
何が原因なのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。