---
title: "session(_:didReceiveMessage:with:from:)"
framework: gamekit
role: symbol
role_heading: Instance Method
path: "gamekit/gkgamesessioneventlistener/session(_:didreceivemessage:with:from:)"
---

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

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

## Declaration

```swift
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

Discussion This event fires after the 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:) method are notified.

## See Also

### Transferring Data

- [session(_:didReceive:from:)](gamekit/gkgamesessioneventlistener/session(_:didreceive:from:).md)
- [session(_:player:didSave:)](gamekit/gkgamesessioneventlistener/session(_:player:didsave:).md)
