18

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.

Kara
  • 6,115
  • 16
  • 50
  • 57
ray
  • 181
  • 1
  • 1
  • 3

4 Answers4

9

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.

Shane Hou
  • 4,808
  • 9
  • 35
  • 50
  • 2
    actually you can but, not how you'd expect. Run the WatchKit app with the play button in xCode. Next on the iPhone simulator, launch your corresponding iOS app. Go back to xCode and select Debug -> Attach to Process. Near the top of the list you should see the target for your iOS app. You can switch between debug consoles by selecting the name above the console window – anders Apr 23 '15 at 14:14
  • It works but messages don't arrive using Watch Connectivity Framework. – OhadM Jan 24 '16 at 09:00
7

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

GoodSp33d
  • 6,252
  • 4
  • 35
  • 67
3

In order to test watch notifications, you must first create a new build scheme.

Duplicate your watch app scheme, and in the "Run" section, choose your custom notification as the executable.

Now you can run the notification scheme.

Inside the extensions group in your project, under Supporting Files is a file called PushNotificationPayload.json.

You can edit the payload file to try different notifications and categories.

Source

Attila O.
  • 15,659
  • 11
  • 54
  • 84
Dreamwieber
  • 422
  • 5
  • 10
1

I only had two targets when I created the projects:

  • [app name]
  • [app name] Watch App

Editing the Watch App scheme allows me to select another executable -- notably there's the Glance and Notification options there, and they work for me. Just select it, close, and run. I haven't tried duplicating the targets/schemes so I don't have to edit them, but I don't think that would be an issue.

Edit: Actually, the SDK tells you to edit the scheme too.

Keilaron
  • 437
  • 4
  • 10