Instance Method

challengeComposeController(withPlayers:message:completionHandler:)

Provides a challenge compose view controller with pre-selected player identifiers and a 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 message that is sent to other players. This message can be edited by the player.

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 that contains the player identifiers and the challenge message.

Discussion

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, Game Kit calls your completion handler. The completion handler is always called on the main thread.

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.

See Also

Deprecated Methods and Properties

var isHidden: Bool

A Boolean value that states whether this achievement is normally kept secret from the player.

Deprecated
init(identifier: String?, forPlayer: String)

Initializes an achievement for a specific player.

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

Issue an achievement challenge to a list of players.

Deprecated
var playerID: String

A string used to identify the player who earned the achievement.

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

Reports the player’s progress to Game Center.

Deprecated
func selectChallengeablePlayerIDs([String]?, withCompletionHandler: (([String]?, Error?) -> Void)?)

Finds the subset of players that can earn an achievement.

Deprecated