<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WatchConnectivity",
  "identifier" : "/documentation/WatchConnectivity/WCSessionDelegate/session(_:didReceiveMessageData:replyHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Watch Connectivity"
    ],
    "preciseIdentifier" : "c:objc(pl)WCSessionDelegate(im)session:didReceiveMessageData:replyHandler:"
  },
  "title" : "session(_:didReceiveMessageData:replyHandler:)"
}
-->

# session(_:didReceiveMessageData:replyHandler:)

Tells the delegate that an immediate data message has arrived, and it requires a response.

```
optional func session(_ session: WCSession, didReceiveMessageData messageData: Data, replyHandler: @escaping (Data) -> Void)
```

## Parameters

`session`

The session object that received the data from its counterpart.

`messageData`

The data object received from the counterpart. Use the contents of this object to determine what course of action to take.

`replyHandler`

A reply block to execute with the response. This block has no return value and takes the following parameter:

- replyMessage: A data object containing your response to `message`.

## Discussion

This method is called in response to a message sent by the counterpart process using the [`sendMessageData(_:replyHandler:errorHandler:)`](/documentation/WatchConnectivity/WCSession/sendMessageData(_:replyHandler:errorHandler:)) method. This specific method is called when the counterpart specifies a valid reply handler, indicating that it wants a response. Use this method to process the message data and provide an appropriate reply. You must execute the `reply` block as part of your implementation.

Use messages to communicate quickly with the counterpart process. Messages can be sent and received only while both processes are active and running.

The delivery of multiple messages occurs serially, so your implementation of this method does not need to be reentrant. This method is called on a background thread of your app.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)