<!--
{
  "documentType" : "article",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/sending-messages-to-players-in-turn-based-games",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Sending messages to players in turn-based games"
}
-->

# Sending messages to players in turn-based games

Notify players of match events by sending messages and game data.

## Discussion

GameKit provides several APIs for you to communicate events and send messages in your turn-based games. You can include a message and custom game data in the [`GKTurnBasedMatch`](/documentation/GameKit/GKTurnBasedMatch) object passed between active participants. You can also send a notification to other participants when they’re not running your game.

To send other types of data between players when they’re not taking their turn, see the [`GKTurnBasedExchange`](/documentation/GameKit/GKTurnBasedExchange) class.

> Important:
> The code listings in this article use GameKit asynchronous methods that you invoke from an `async` method or within a `Task` structure. For details on asynchronous flows, see [Concurrency](https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html).

### Pass messages from the current participant

You can send localized or non-localized messages from the current participant to others in a turn-based match using the [`GKTurnBasedMatch`](/documentation/GameKit/GKTurnBasedMatch) object. If the game isn’t running or is in the background, the message you provide appears immediately at the top of the screen as a notification. If the game is in the foreground, get the message from the match object GameKit passes to participants and display it in your own interface.

Before you perform an action such as ending a turn, set the [`message`](/documentation/GameKit/GKTurnBasedMatch/message) property of the match object. Alternatively, set a message that GameKit localizes using the receiving participant’s language and region settings using the [`setLocalizableMessageWithKey(_:arguments:)`](/documentation/GameKit/GKTurnBasedMatch/setLocalizableMessageWithKey(_:arguments:)) method.

```swift
match.message = "We're all counting on you!"
try await match.endTurn(withNextParticipants: nextParticipants, turnTimeout: GKTurnTimeoutDefault, match: gameData)
```

If a participant taps the notification when it appears, GameKit launches the game or brings it to the foreground. GameKit invokes the `GKTurnBasedEventListener` [`player(_:receivedTurnEventFor:didBecomeActive:)`](/documentation/GameKit/GKTurnBasedEventListener/player(_:receivedTurnEventFor:didBecomeActive:)) protocol method passing <doc://com.apple.documentation/documentation/Swift/true> as the active parameter. Implement this method to join the match. For more information on handling turn-based events, see [Starting turn-based matches and passing turns between players](/documentation/GameKit/starting-turn-based-matches-and-passing-turns-between-players).

If the game is in the foreground, GameKit invokes this method but passes <doc://com.apple.documentation/documentation/Swift/false> as the active parameter. You can then present the message in your own interface by getting the message from the match object using the [`message`](/documentation/GameKit/GKTurnBasedMatch/message) property.

To localize a message, add the key you pass to the [`setLocalizableMessageWithKey(_:arguments:)`](/documentation/GameKit/GKTurnBasedMatch/setLocalizableMessageWithKey(_:arguments:)) method and a placeholder translation to a `.strings` file in your project (for example, the default `Localizable.strings` file). For more information on adapting your game for different languages and regions, see <doc://com.apple.documentation/documentation/Xcode/localization>.

### Send messages from any participant

Send a localized message from any participant to others using a Game Center notification. For example, send a reminder to the current participant from another participant who is waiting for them to take their turn. GameKit sends the reminder to the participants as a push notification that doesn’t interrupt their gameplay. The notification only appears when the game isn’t running — it doesn’t appear if the participant runs the game in either the foreground or background.

![A screenshot of the Game Center notification reminder at the top of a phone screen. The notification shows the game name at the top and the message “It’s your turn to play.” at the bottom.](images/com.apple.gamekit/media-3894240@2x.png)

To display the GameKit notification:

1. Invoke the `GKTurnBasedMatch` [`sendReminder(to:localizableMessageKey:arguments:completionHandler:)`](/documentation/GameKit/GKTurnBasedMatch/sendReminder(to:localizableMessageKey:arguments:completionHandler:)) method passing the participants and a localized message key:

```swift
// Create an array that contains the current participant.
let participants = match.participants.filter {
    $0 == match.currentParticipant
}

// Send a reminder to the current participant.
try await match.sendReminder(to: participants, localizableMessageKey: "It's your turn to play.", arguments: [])
```

1. Add the localized message key and placeholder translation to a  `.strings` file in your project. If necessary, add a `.strings` file (for example, the default `Localizable.strings` file) to your project and make it localizable. For the Xcode steps, see <doc://com.apple.documentation/documentation/Xcode/adding-resources-to-localizations> and `Editing XLIFF and strings files`.

```swift
"It's your turn to play." = "It's your turn to play.";
```

When the player taps the notification, GameKit invokes the `GKTurnBasedEventListener` [`player(_:receivedTurnEventFor:didBecomeActive:)`](/documentation/GameKit/GKTurnBasedEventListener/player(_:receivedTurnEventFor:didBecomeActive:)) protocol method passing <doc://com.apple.documentation/documentation/Swift/true> as the active parameter. Implement this method to join the existing match. For more information on handling turn-based events, see [Starting turn-based matches and passing turns between players](/documentation/GameKit/starting-turn-based-matches-and-passing-turns-between-players).

> Note:
> If you exceed the system’s 10-minute limit for the frequency of sending reminders, a `GKServerTurnBasedMaxSessionOtherError` error occurs.

---

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)