---
title: "getShareURL(completionHandler:)"
framework: gamekit
role: symbol
role_heading: Instance Method
path: "gamekit/gkgamesession/getshareurl(completionhandler:)"
---

# getShareURL(completionHandler:)

Retrieves the URL used to share a game session.

## Declaration

```swift
func getShareURL(completionHandler: @escaping @Sendable (URL?, (any Error)?) -> Void)
```

```swift
func shareURL() async throws -> URL
```

## Parameters

- `completionHandler`: A block that is called after the shared URL has been retrieved.

## Discussion

Discussion When a player clicks the Share or Invite button in your app, they have indicated they want to interact with another player. This method to retrieves a URL used to invite other players into the current game session. The completion handler for this method returns an optional URL and Error. After ensuring you have a valid URL, you should immediately present the player with the option to share their game session by sending the URL to another player or friend. This is accomplished by configuring a UIActivityViewController and presenting it. You must implicitly unwrap the URL when creating the activity view controller. For example, the listing below presents the shared URL on an iPad. @IBAction func invitePlayerWithMessages(sender: UIButton) {         myGameSession.getShareURL(completionHandler:  { (url, error) in             if error == nil {                 let activityVC = UIActivityViewController.init(activityItems: [url!], applicationActivities: nil)                 activityVC.popoverPresentationController?.sourceView = sender                 self.present(activityVC, animated: true, completion: nil)                              } else {                 // .. Process the error             }         })     } After the URL has been shared, your app must handle any requests to join the game session.
