I've a todo app and I need a notification to be displayed to the watch at the scheduled todo time. How do I do this? I've read that iOS local notification automatically fires notification in the watch. Is it possible? If yes, do I need to add any code in extra to do so?
-
Yeah, you are correct @Naveen. "The operating system is responsible for delivering local notifications at their scheduled times; the app does not have to be running for this to happen." - [Apple Documentation](https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/). You need to add a code for Local Notifications. Get more clear for a particular ToDo from [here](http://stackoverflow.com/questions/20110805/fire-a-notification-at-a-specific-day-and-time-every-week). Hope this might help you. – iYoung Apr 22 '15 at 05:09
-
Thanks @Rajat. Will the notification scene we've made for the watch app appear when the iPhone app fires the local notification? – Naveen George Thoppan Apr 22 '15 at 05:37
-
Yes it will be shown on the watch. – iYoung Apr 22 '15 at 05:44
2 Answers
In watchOS 3, you no longer need a need to use the phone to schedule a notification.
You can now use the new UserNotifications framework to schedule local notifications directly on the watch. These notifications will only appear on and be handled by the watch.
The WWDC 2016 Introduction to Notifications session covers how you can use different types of triggers to fire off your todo notification, such as:
Time interval triggers
// In 2 minutes from now UNTimeIntervalNotificationTrigger(timeInterval: 120, repeats: false) // Repeat every hour starting now UNTimeIntervalNotificationTrigger(timeInterval: 3600, repeats: true)
Calendar triggers
let dateComponents = DateComponents() // Configure dateComponents UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
The session also covers how to handle actionable notifications on the watch.
The concept of a UILocalNotification
hasn't changed with WatchKit. The only thing that has changed is that iOS can now decide whether to send a local (or remote) notification to either the iPhone or the Watch. There is no programmatic way to control which of these devices actually displays the notification, though.
To schedule a UILocalNotification
from a WatchKit app requires using something like the openParentApplication:reply:
class method on WKInterfaceController
to have the iPhone app do the actual scheduling. This is because WatchKit doesn't have access to UIApplication
, the class that is used to schedule local notifications.

- 3,337
- 1
- 17
- 15
-
If I set the local notification in the iOS app, will the notification be displayed to the watch automatically? – Naveen George Thoppan Apr 22 '15 at 05:35
-
Only if iOS decides to show it on the watch. Remember...you have no control over where the notification will be displayed. – Mike Swanson Apr 22 '15 at 05:45
-
the device must be locked to receive notifications in your apple watch – WhiteTiger May 19 '15 at 22:32
-
Or, for debugging, you can go into the Watch companion app on your iPhone and disable General/Wrist Detection. – Mike Swanson May 20 '15 at 01:19