---
title: "cancel(withLocalizableMessageKey:arguments:completionHandler:)"
framework: gamekit
role: symbol
role_heading: Instance Method
path: "gamekit/gkturnbasedexchange/cancel(withlocalizablemessagekey:arguments:completionhandler:)"
---

# cancel(withLocalizableMessageKey:arguments:completionHandler:)

Cancels an exchange request.

## Declaration

```swift
func cancel(withLocalizableMessageKey key: String, arguments: [String], completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

```swift
func cancel(withLocalizableMessageKey key: String, arguments: [String]) async throws
```

## Parameters

- `key`: The identifier for looking up the translated cancel message in the default Localized.strings file. If you use a formatted string with specifiers, provide the arguments.
- `arguments`: A list of arguments to substitute into the localized string if it’s formatted and contains specifiers.
- `completionHandler`: The block that GameKit calls when it completes the request. The block receives the following parameter:

## Mentioned in

Exchanging data between players in turn-based games

## Discussion

Discussion You can cancel both an active and completed exchange request. If your game isn’t running or is in the background on recipient devices, a notification containing the localized message you provide appears. When the participant taps or clicks the notification, GameKit launches or brings the game to the foreground and then invokes the player(_:receivedExchangeCancellation:for:) protocol method.
