Instance Method

challengeComposeController(withPlayers:message:completionHandler:)

Provides a challenge compose view controller with pre-selected player identifiers and a preformatted, player-editable message.

Declaration

func challengeComposeController(withPlayers playerIDs: [String]?, message: String?, completionHandler: GKChallengeComposeCompletionBlock? = nil) -> UIViewController?

Parameters

playerIDs

An array of NSString objects that contains the player identifiers that the challenge is to be sent to.

message

The preformatted, player-editable message that is being sent to other players.

completionHandler

A block to be called after the view controller has been displayed. Contains the reason the handler was called and all player identifiers that the challenge was sent to.

Return Value

A UIViewController view containing the player identifiers and a player-editable message.

Discussion

The view controller returned is presented modally from the top view controller. After the view controller is displayed and the player sends or cancels the challenge, the completion handler block is called.

When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, GameKit calls your completion handler. The completion handler is always called on the main thread.

See Also

Deprecated Methods and Properties

var category: String?

The leaderboard that this score belongs to.

Deprecated
init(category: String?)

Returns an initialized score object.

Deprecated
init(leaderboardIdentifier: String, forPlayer: String)

Returns an initialized score object for the specified leaderboard and player.

Deprecated
func issueChallenge(toPlayers: [String]?, message: String?)

Issues a score challenge to a set of players.

Deprecated
var playerID: String

The player identifier for the player that earned the score.

Deprecated
func report(completionHandler: ((Error?) -> Void)?)

Reports a score to Game Center.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software