Search code examples
iosswiftwatchkitapple-watch

WatchKit - Handle push notification and send data back to server


I'm a little bit confused about push notification implementation from the Watch app side.

I need to implement the following simple scenario:
1. Server sends a push notification
2. Watch app receives the notification and display a yes-no question to the user
3. The user clicks on Yes/No button, and a response should be sent back to the server

I'm not sure I understood wether the Watch app itself should trigger the network response back to the server? or should it be done via the iOS app?

Thanks in advance!


Solution

  • It is up to you, which approach you take, both can work.

    However, I'd suggest sending the network request directly from the Watch app, since this way you can ensure that there's no dependency on the state of the iOS app and hence the request will be sent ASAP. Meanwhile, if you wanted to handle the network request from the iOS app, you'd need to use the WatchConnectivity framework to send the request date from your Watch app to the iOS app, which means the iOS app would need to be running at least in the background, otherwise WatchConnectivity cannot be used.