Search code examples
iosiphoneipcwatchkit

Sending messages from parent app to WatchKit Interface


I can send a message from my WatchKit Interface to its parent application using +openParentApplication:reply:, and I can provide data from the parent application in the reply.

Is there an official Apple mechanism for triggering a message in the other direction, ideally an Objective-C API with similar support for arbitrary user data, or do I have to use a library like MMWormhole?


Solution

  • The openParentApplication:reply: does have that reply parameter for sending a message back to the WatchKit side.

    But I think you mean triggering a message from the iPhone app directly. You can look into Darwin notifications for this. It's a C API, but the concepts are similar to NSNotificationCenter where you register to listen for certain notifications, and then post notifications from somewhere else.