-4
月の最初の日に通知を送信したいと思います。どうやってやるの?これは、ローカルではないリモートのみの通知です。Swift 3の特定の日付に通知を送信する方法
月の最初の日に通知を送信したいと思います。どうやってやるの?これは、ローカルではないリモートのみの通知です。Swift 3の特定の日付に通知を送信する方法
特定の日付の通知のためにこのコードが必要です。
let alarmTime = Date().addingTimeInterval(60 * 60 * 24 * 7 - 300) /// you should make changes here according to your requirement.
let components = Calendar.current.dateComponents([.weekday, .hour, .minute], from: alarmTime)
let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: true)
let content = UNMutableNotificationContent()
content.title = "Notification Demo"
content.subtitle = "Demo"
content.body = "Notification on specific date!!"
let request = UNNotificationRequest(
identifier: "identifier",
content: content,
trigger: trigger
)
は、最初のあなたは
func scheduleLocal(sender: AnyObject) {
let notification = UILocalNotification()
notification.fireDate = // give the next first date
notification.alertBody = "this is your notification"
notification.alertAction = "be awesome!"
notification.soundName = UILocalNotificationDefaultSoundName
notification.repeatInterval = NSCalendarUnit.NSCalendarUnitMonth
notification.userInfo = ["CustomField1": "w00t"]
UIApplication.sharedApplication().scheduleLocalNotification(notification)
まずあなたがしようとした – Alistra
が見削減しないでください動作しませんでしたどのような私たちを見ると、スケジュール
として通知迅速に登録する必要があります私の質問の投票。私は通知を送るために最低限の消費をしてきました。私が得たのはコードだけですが、どこでこのコードを書いていますか?私は初心者です。質問の投票を減らし、スタックオーバーフローで質問することは不可能です。私はこれにうんざりです!!!! –