Sends a message immediately to the paired and active device and optionally handles a response.
- iOS 9.0+
- watchOS 2.0+
A dictionary of property list values that you want to send. You define the contents of the dictionary that your counterpart supports. This parameter must not be
A reply handler for receiving a response from the counterpart. Specify
nilif you do not want to receive a reply. This block has no return value and takes the following parameter:
A dictionary of property list values containing the response from the counterpart.
A block that is executed when an error occurs. Specify
nilif you do not care about error information. This block has no return value and takes the following parameter:
An error object containing the reason for the failure. When sending messages, the most common error is that the paired device was not reachable, but other errors may occur too.
Use this message to send a dictionary of data to the counterpart as soon as possible. Messages are queued serially and delivered in the order in which you sent them. Delivery of the messages happens asynchronously, so this method returns immediately.
If you specify a reply handler block, your handler block is executed asynchronously on a background thread. The block is executed serially with respect to other incoming delegate messages.
Calling this method from your WatchKit extension while it is active and running wakes up the corresponding iOS app in the background and makes it reachable. Calling this method from your iOS app does not wake up the corresponding WatchKit extension. If you call this method and the counterpart is unreachable (or becomes unreachable before the message is delivered), the
error block is executed with an appropriate error. The
error block may also be called if the
message parameter contains non property list data types.
This method can only be called while the session is active—that is, the
activation property is set to
WCSession. Calling this method for an inactive or deactivated session is a programmer error.