Search code examples
iosapple-watchunusernotificationcenter

Apple watch local notification not working when the watch isn't worn


We are using the UNUserNotification framework provided by WatchOS 3.0 to create local notification to notify user at a predefined moment. However, the notification is not shown when the watch is not being worn on the wrist. It does work well when someone is wearing it.

We cannot find this description on any documentation. Is that normal? If yes, how to help the user to avoiding missing some notifs ?

UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
            // Enable or disable features based on authorization.
            if granted {
                let content = UNMutableNotificationContent()
                content.title = title
                content.body = body
                content.sound = UNNotificationSound.default()
                content.userInfo = userInfo
                let trigger = UNTimeIntervalNotificationTrigger.init(
                    timeInterval: interval,
                    repeats: false)

                let identifier = stringWithUUID()
                let request = UNNotificationRequest.init(
                    identifier: identifier,
                    content: content,
                    trigger: trigger
                )
                UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
                completion?(true, nil)
            }
            else {
                completion?(false, error)
            }
        }

Solution

  • This is normal, Apple Watch automatically locks when you take it off your wrist and notifications go to your iPhone instead.