<!--
{
  "availability" : [
    "iOS: 10.0.0 - 12.0.0",
    "iPadOS: 10.0.0 - 12.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.12.0 - 10.14.0",
    "tvOS: 10.0.0 - 12.0.0",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKGameSessionEventListener/session(_:didReceiveMessage:with:from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(pl)GKGameSessionEventListener(im)session:didReceiveMessage:withData:fromPlayer:"
  },
  "title" : "session(_:didReceiveMessage:with:from:)"
}
-->

# session(_:didReceiveMessage:with:from:)

Tells the listener a player has received a message from another player.

```
optional func session(_ session: GKGameSession, didReceiveMessage message: String, with data: Data, from player: GKCloudPlayer)
```

## Parameters

`session`

The game session the sending player is associated with.

`message`

A `String` containing the message sent to other players.

`data`

Any data associated with the message. The value of this parameter can be `nil`.

`player`

The player who sent the message.

## Discussion

This event fires after the [`sendMessage(withLocalizedFormatKey:arguments:data:to:badgePlayers:completionHandler:)`](/documentation/GameKit/GKGameSession/sendMessage(withLocalizedFormatKey:arguments:data:to:badgePlayers:completionHandler:)) method has been called. Only players contained in the `players` argument of the [`sendMessage(withLocalizedFormatKey:arguments:data:to:badgePlayers:completionHandler:)`](/documentation/GameKit/GKGameSession/sendMessage(withLocalizedFormatKey:arguments:data:to:badgePlayers:completionHandler:)) method are notified.

---

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)