Hey everyone! So recently I've been developing local notifications on watchOS 3.0 using the new UNNotification classes. I've been able to get through it no problem, but am now curious about something. If I schedule a notification for a point in time where the user does not have their watch on, or is locked, what should be the expected outcome? As of now, I am not receiving any notifications which is a bummer, but would hope that I can figure how to fix it. Thanks in advance for your time! - Alec
UNNotifications and locked Apple Watch
There is an update on this issue. I wanted to first list my general build information for clarity:
Test Device: Apple Watch Series 1
Version: watchOS 3.1
Language: Swift 2.3
Issue Regarding: UNUserNotificationCenter
I ran a test where I created a context menu action that ran this line of code:
let center = UNUserNotificationCenter.currentNotificationCenter()
center.getDeliveredNotificationsWithCompletionHandler { (notifications) in
print("Delivered: \(notifications)")
}
I wanted to be able to see if my notification was actually delivered or was just lost forever.
My first step was to create an UNNotification Request that would be delivered within 1 minute. After the request is scheduled I immediately took off my watch so it would lock (My watch has a passcode on it). I waited until the expected notification was suppose to be delivered, went back to my app and used the context menu item to get the delivered items in my center.
As stated in Apple's Documentation, that line of code should return an array of notifications that are STILL VISIBLE IN THE NOTIFICATION CENTER:
"An array of UNNotification objects representing the local and remote notifications of your app that have been delivered and are still visible in Notification Center. If none of your app’s notifications are visible in Notification Center, the array is empty."
Catch is, they are not visible in the notification center at all making me think that this is a bug and I should file a radar for it. I would love some input from anyone else who might have experience with this. Thanks in advance!