Instance Method

getShareURLWithCompletionHandler:

Retrieves the URL used to share a game session.

Declaration

- (void)getShareURLWithCompletionHandler:(void (^)(NSURL *url, NSError *error))completionHandler;

Parameters

completionHandler

A block that is called after the shared URL has been retrieved.

url

An NSURL object that contains the URL sent to other players in order to invite them to a game session.

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

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.

After the URL has been shared, your app must handle any requests to join the game session.