Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger notifications using WatchKit

In the WatchKit developer guide, there are instructions on how to render custom notifications and it also says:

Apps are not required to do anything to support notifications. The system provides a default notification interface that displays the alert message from the notification. However, apps can customize the notification interface and include custom graphics, content, and branding.

I can get local notifications to trigger banner alerts on the phone, but they don't happen on the WatchKit app. I have tried debugging using all of the targets:

  1. iOS app
  2. Watch app
  3. Watch Glance
  4. Watch custom notification

Even while the phone app is in the background, none seem to trigger when the local notification is received. I have also tried this by simulating a remote notification being received in the background.

I'm hoping I don't have to call the watchKit's controller local/remote notification handlers directly.

like image 509
ray Avatar asked Nov 24 '14 03:11

ray


2 Answers

I'm hoping I don't have to call the watchKit's controller local/remote notification handlers directly.

No, you don't.

The answer is XCode doesn't support debugging Apple Watch and iPhone simultaneously for now. That's why you can't push a notification from iPhone simulator to Watch simulator, only payload test by *.apns files is supported for now.

like image 63
Reck Hou Avatar answered Sep 28 '22 18:09

Reck Hou


Its explained in Notification Essentials that

iOS decides whether to display that notification on the iPhone or on Apple Watch .

So I dont think(as of now) there is anything that can be done from the app to trigger Notifications specifically in the watch.

Edit: It looks like theres a bug in 8.2 beta.

WatchKit Known Issues

When viewing a notification in iOS simulator, clicking on the notification icon or body does not launch the corresponding Watch app

Release notes

like image 44
GoodSp33d Avatar answered Sep 28 '22 18:09

GoodSp33d