how to programatically trigger notification on the watch from my iOS app

43 views Asked by At

So this feels like it should be a common question here on StackOverflow and Apple's dev forums, but all the question/answers I have found date from long before 2024. The TLDR version of this question is: How to get my iOS app to trigger a notification that appears ONLY on the watch.

While a regular vanilla local notification might appear on either the phone or the watch (depending on each devices locked state), my use case needs to always alert the watch (as this particular app is used by deaf folks that may not be presently looking at their unlocked phone)

I'd be thrilled if this were as easy as simply setting up some UNNotification on the iOS app where I can target it to get displayed on any watch the phone is paired with.

According to this older answer, I might be able to do what I need via a WatchKit Extension. Anyone have any pointers to the modern solution?

2

There are 2 answers

2
Paulw11 On BEST ANSWER

There is no way to direct a notification to the watch from your iOS app. As you say in your question, iOS will decide whether to route a notification to the watch based on whether they think the user is currently looking at their phone, whether it is locked and so on.

The only way to force the notification to be shown on the watch is for you to add a watch app to your iOS app. Then your iOS app can send a message to your watch app via WCSession and the watch app can post a local notification. Notifications generated by watch apps are always shown only on the watch.

0
闪电狮 On

I have the same needs, and I need to trigger notifications on the user's watch.

[The requires users to install a companion app on the watch with your iOS app]

I found that the watch app can support APNs services, so I used Google's Cloud Message to do this.

Next, I can trigger a Google Cloud Message in the iOS app, and then the notification will be directly pushed to the watch (whether the user is currently using the phone/watch or not, the notification will always be pushed to the watch).