<!--
{
  "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/GKGameSession/sendMessage(withLocalizedFormatKey:arguments:data:to:badgePlayers:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKGameSession(im)sendMessageWithLocalizedFormatKey:arguments:data:toPlayers:badgePlayers:completionHandler:"
  },
  "title" : "sendMessage(withLocalizedFormatKey:arguments:data:to:badgePlayers:completionHandler:)"
}
-->

# sendMessage(withLocalizedFormatKey:arguments:data:to:badgePlayers:completionHandler:)

Sends a message to players in a game session.

```
func sendMessage(withLocalizedFormatKey key: String, arguments: [String], data: Data?, to players: [GKCloudPlayer], badgePlayers: Bool, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`key`

A localized string with format tokens.

`arguments`

An array containing entries for the format tokens contained by the `key` parameter.

`data`

A `Data` object containing a limited amount of developer determined game information.

`players`

A `GKCloudPlayer` array containing the players to be messaged.

`badgePlayers`

A `Boolean` indicating whether players are badged when the message is sent.

`completionHandler`

A block that is called after the message has been sent.

- error: If an error occurred, this parameter holds an error object that explains the error. Otherwise, the value of this parameter is nil. See `GameKit Constants` for a list of error codes specific to GameKit.

## Discussion

---

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)