GKChallengeListener Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/GameKit.framework
Availability
Available in iOS 7.0 and later.
Companion guide
Declared in
GKEventListener.h

Overview

Provides methods for responding to challenge events. Your app can ignore a challenge, start up in a specific state so the player can respond to a challenge, or notify the original challenger when the local player completes a challenge.

Do not implement GKChallengeListener directly, instead use GKLocalPlayerListener. The GKLocalPlayerListener protocol inherits methods from GKChallengeListener, GKInviteEventListener, and GKTurnBasedEventListener in order to handle multiple events.

Tasks

Responding to a Challenge

Completing a Challenge

Instance Methods

player:didCompleteChallenge:issuedByFriend:

Called when the player completes a challenge that was issued by a friend. (required)

- (void)player:(GKPlayer *)player didCompleteChallenge:(GKChallenge *)challenge issuedByFriend:(GKPlayer *)friendPlayer
Parameters
player

The player who completed the challenge.

challenge

The challenge the player completed.

friendPlayer

The friend who originally sent the challenge.

Discussion

This method is triggered when the game is running or when the user has tapped a challenge notification banner outside of the game.

Availability
  • Available in iOS 7.0 and later.
Declared In
GKEventListener.h

player:didReceiveChallenge:

Called when a player receives a challenge and doesn’t want to address it immediately. (required)

- (void)player:(GKPlayer *)player didReceiveChallenge:(GKChallenge *)challenge
Parameters
player

The player that receives the challenge.

challenge

The challenge sent to the player.

Availability
  • Available in iOS 7.0 and later.
Declared In
GKEventListener.h

player:issuedChallengeWasCompleted:byFriend:

Called when a friend completes a challenge that was sent to them by the player. (required)

- (void)player:(GKPlayer *)player issuedChallengeWasCompleted:(GKChallenge *)challenge byFriend:(GKPlayer *)friendPlayer
Parameters
player

The player who originally sent the challenge.

challenge

The challenge that was created and sent.

friendPlayer

The player that completed the challenge.

Discussion

This method is triggered when the game is running or when the user has tapped a challenge notification banner outside of the game.

Availability
  • Available in iOS 7.0 and later.
Declared In
GKEventListener.h

player:wantsToPlayChallenge:

Called when a player wants to start a game with the intention of completing a challenge. (required)

- (void)player:(GKPlayer *)player wantsToPlayChallenge:(GKChallenge *)challenge
Parameters
player

The player who selected the challenge.

challenge

The challenge to be played by the player.

Availability
  • Available in iOS 7.0 and later.
Declared In
GKEventListener.h