Mac Developer Library

Developer

GameKit Framework Reference GKChallengeEventHandlerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

GKChallengeEventHandlerDelegate

You implement the GKChallengeEventHandlerDelegate delegate to control how challenges are displayed in your game.

By default, Game Kit briefly displays a banner over your game when any of the following events occur:

  • The local player receives a challenge.

  • The local player completes a challenge.

  • A remote player completes a challenge issued by the local player.

Your event handler can override or extend this behavior:

  • It can prevent a banner from being displayed.

  • It can be notified when a player taps in a banner.

  • It can handle the events directly.

Inheritance


Not Applicable

Import Statement


Swift

import GameKit

Objective-C

@import GameKit;

Availability


Available in OS X v10.8 and later.
Deprecated in OS X v10.10.
  • Called when the local player selects a challenge banner displayed by Game Kit.

    Declaration

    Swift

    optional func localPlayerDidSelectChallenge(_ challenge: GKChallenge!)

    Objective-C

    - (void)localPlayerDidSelectChallenge:(GKChallenge *)challenge

    Parameters

    challenge

    The selected challenge.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.

  • Called when the local player receives a new challenge.

    Declaration

    Swift

    optional func localPlayerDidReceiveChallenge(_ challenge: GKChallenge!)

    Objective-C

    - (void)localPlayerDidReceiveChallenge:(GKChallenge *)challenge

    Parameters

    challenge

    The received challenge.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.

  • Called to determine whether a banner should be shown when the local player receives a challenge.

    Declaration

    Swift

    optional func shouldShowBannerForLocallyReceivedChallenge(_ challenge: GKChallenge!) -> Bool

    Objective-C

    - (BOOL)shouldShowBannerForLocallyReceivedChallenge:(GKChallenge *)challenge

    Parameters

    challenge

    The received challenge.

    Return Value

    Your delegate should return YEStrue if it wants a banner to be displayed. Otherwise it should return NOfalse.

    Discussion

    If you do not implement this method, a banner is always shown.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.

  • Called when the local player completes a challenge.

    Declaration

    Swift

    optional func localPlayerDidCompleteChallenge(_ challenge: GKChallenge!)

    Objective-C

    - (void)localPlayerDidCompleteChallenge:(GKChallenge *)challenge

    Parameters

    challenge

    The completed challenge.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.

  • Called to determine whether a banner should be shown when the local player completes a challenge.

    Declaration

    Swift

    optional func shouldShowBannerForLocallyCompletedChallenge(_ challenge: GKChallenge!) -> Bool

    Objective-C

    - (BOOL)shouldShowBannerForLocallyCompletedChallenge:(GKChallenge *)challenge

    Parameters

    challenge

    The completed challenge.

    Return Value

    Your delegate should return YEStrue if it wants a banner to be displayed. Otherwise it should return NOfalse.

    Discussion

    If you do not implement this method, a banner is always shown.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.

  • Called when a remote player completes a challenge issued by the local player.

    Declaration

    Swift

    optional func remotePlayerDidCompleteChallenge(_ challenge: GKChallenge!)

    Objective-C

    - (void)remotePlayerDidCompleteChallenge:(GKChallenge *)challenge

    Parameters

    challenge

    The completed challenge.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.

  • Called to determine whether a banner should be shown when a remote player completes a challenge.

    Declaration

    Swift

    optional func shouldShowBannerForRemotelyCompletedChallenge(_ challenge: GKChallenge!) -> Bool

    Objective-C

    - (BOOL)shouldShowBannerForRemotelyCompletedChallenge:(GKChallenge *)challenge

    Parameters

    challenge

    The completed challenge.

    Return Value

    Your delegate should return YEStrue if it wants a banner to be displayed. Otherwise it should return NOfalse.

    Discussion

    If you do not implement this method, a banner is always shown.

    Import Statement

    Objective-C

    @import GameKit;

    Swift

    import GameKit

    Availability

    Available in OS X v10.8 and later.

    Deprecated in OS X v10.10.