I'm attempting to schedule a local notification on WatchOS with the following code, but nothing is showing on the watch.
// sending notifications
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound]) { (granted, error) in
// Enable or disable features based on authorization.
print("hello?")
}
let content = UNMutableNotificationContent()
content.title = NSString.localizedUserNotificationString(forKey: "Hello!", arguments: nil)
content.body = NSString.localizedUserNotificationString(forKey: "Hello_message_body", arguments: nil)
content.sound = UNNotificationSound.defaultCritical
content.categoryIdentifier = "REMINDER_CATEGORY"
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 1, repeats: false)
let id = String(Date().timeIntervalSinceReferenceDate)
let request = UNNotificationRequest(identifier: id, content: content, trigger: trigger)
center.add(request, withCompletionHandler: {(_ error: Error?) -> Void in
if error != nil {
print("Something went wrong: \(String(describing: error))")
} else {
print("notif triggered successfully")
}
})
The "notif triggered successfully" print is showing in the logs. Any ideas on what might be happening here? Thank you!