<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameKit",
  "identifier" : "/documentation/GameKit/GKTurnBasedExchange/cancel(withLocalizableMessageKey:arguments:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKTurnBasedExchange(im)cancelWithLocalizableMessageKey:arguments:completionHandler:"
  },
  "title" : "cancel(withLocalizableMessageKey:arguments:completionHandler:)"
}
-->

# cancel(withLocalizableMessageKey:arguments:completionHandler:)

Cancels an exchange request.

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

## 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:

- *error*: Describes an error if it occurs, or `nil` if the operation completes. An error occurs if you previously cancel this exchange request.

## 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:)`](/documentation/GameKit/GKTurnBasedEventListener/player(_:receivedExchangeCancellation:for:)) protocol method.

---

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)