Search code examples
iosapple-push-notificationswatchkitapple-watchapple-watch-complication

Apple Watch - how do I schedule a complication update to be in synch with Push notification?


I am writing a conference App in which participants can check the schedule of talks, with time and room number. User's select the talks they are interested in. The watch app displays the user's next upcoming talk as a complication.

In case a talk is delayed or has a room change we will send push notifications to all attendees for that talk. The app also updates the complication at regular intervals (every 30 minutes) If the user picks the push notification on her app or watch, the complication gets updated.

There is one use case for this setup which does not jive: If a push notification is received on the phone or app and the user sees the room time change on the push but does NOT pick the push, then the message on the push will be out of synch with the complication.

For example: The complication shows: 1:15p Rm 1F Complication is scheduled for a 30 min interval update. The push comes in at 1:10pm with "Your next event 'Global Warming' is delayed to 1:45pm" but the user does not pick it. Complication will continue to show 1:15pm until 1:30pm

Any way to avoid this?


Solution

  • You can implement Background Fetch and force the complication update, this way you will have next schemes:

    iOS: Implement application:didReceiveRemoteNotification:fetchCompletionHandler: on the UIApplicationDelegate and fetch there a push notification. After that transfer fetched data using WatchConnectivity to Watch and force the complication update.

    watchOS: Implement didReceiveRemoteNotification: on the WKExtensionDelegate and just force the complication update after the successful fetching.