iOS Developer Library

Developer

GameKit Framework Reference GKChallengeListener Protocol Reference

Options
Deployment Target:

On This Page
Language:

GKChallengeListener

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.

  • Called when the player completes a challenge that was issued by a friend.

    Declaration

    Swift

    optional func player(_ player: GKPlayer, didCompleteChallenge challenge: GKChallenge, issuedByFriend friendPlayer: GKPlayer)

    Objective-C

    - (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.

  • Called when a friend completes a challenge that was sent to them by the player.

    Declaration

    Swift

    optional func player(_ player: GKPlayer, issuedChallengeWasCompleted challenge: GKChallenge, byFriend friendPlayer: GKPlayer)

    Objective-C

    - (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.