WatchKit sendMessage wakes up iPhone app

According to the docs, calling WatchKit's sendMessage on an Apple Watch app extension wakes up the corresponding iPhone app in the background. This enables the iPhone app to provide the Watch app with data it needs, even if the iPhone app is currently not in the foreground.

Unfortunatelly, I cannot find much information about this process. I'd like to know the answer to these questions:

  • Is there a special launchOptions key present when the iPhone app starts up in the background? According to these docs, an empty launchOptions indicates that the user started the app from the home screen - all other startup reasons have their own launchOptions key. However, when testing the wakeup, I get an empty launchOptions.
  • Are there other options that can be used to detect that the iPhone app runs in the background? For example, I expected [UIScreen mainScreen] to be nil because in the background we do not have screens and windows, but there seems to be no difference in mainScreen in the background process.
  • Are there any limits to the background process? For example, is there a limit in how long it can run?
  • Is there a way I can debug such a background process in XCode? Can I tell XCode "wait until the app runs on the iPhone", such that the debugger gets attached as soon as the app runs?

Did you ever get a reply to this? Most of my apps of the watch were initiated by the watch, which woke the iPhone and then potentially sent a message out on the network (and received messages as well).

But now I have the issue where an MQTT message needs to be received by the iPhone and then forwarded to the watch. Since the phone is in the background, that won't work.

So I was wondering if the watch could wake up the phone for some period of time - and have it wait for messages (or if MQTT saves the messages). This fits your question of "how long can background process run).

WatchKit sendMessage wakes up iPhone app
 
 
Q