0
func scheduleNotification(inSeconds: TimeInterval, completion: @escaping (_ Success: Bool) ->()) {
let notif = UNNotificationContent()
notif.title = NSString.localizedUserNotificationString(forKey: "New Notification", arguments: nil)
notif.subtitle = "These are great!"
notif.body = "The new notification options are awesome!"
let notifTrigger = UNTimeIntervalNotificationTrigger(timeInterval: inSeconds, repeats: false)
let request = UNNotificationRequest(identifier: "myNotification", content: notif, trigger: notifTrigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: {error in
if error != nil {
print(error)
completion(false)
} else {
completion(true)
}
})
}
我跟隨Udemy視頻一起關注,並且遇到了設置本地通知的標題,副標題和正文的問題。我得到了所有三個賦值行的相同錯誤。聲明本地通知的標題,副標題和主體
不能分配給屬性:'xxx'是一個只讀屬性。