objc2-game-kit 0.3.2

Bindings to the GameKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

extern_protocol!(
    /// GKChallengeEventHandler's delegate must implement the following protocol to be notified of challenge-related events. All of these methods are called on the main thread.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkchallengeeventhandlerdelegate?language=objc)
    #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
    pub unsafe trait GKChallengeEventHandlerDelegate: NSObjectProtocol {
        #[cfg(feature = "GKChallenge")]
        /// Called when the user taps a challenge notification banner or the "Play Now" button for a challenge inside Game Center, causing the game to launch. Also called when the user taps a challenge banner inside the game.
        ///
        /// # Safety
        ///
        /// `challenge` might not allow `None`.
        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
        #[optional]
        #[unsafe(method(localPlayerDidSelectChallenge:))]
        #[unsafe(method_family = none)]
        unsafe fn localPlayerDidSelectChallenge(&self, challenge: Option<&GKChallenge>);

        #[cfg(feature = "GKChallenge")]
        /// If the method returns YES, a challenge banner (like an achievement or welcome banner -- not a notification center banner) is displayed when a challenge is received in-game for the local player. If NO, then no banner is displayed, and localPlayerDidSelectChallenge: will not be called for that challenge. Default behavior for non-implementing apps is YES.
        ///
        /// # Safety
        ///
        /// `challenge` might not allow `None`.
        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
        #[optional]
        #[unsafe(method(shouldShowBannerForLocallyReceivedChallenge:))]
        #[unsafe(method_family = none)]
        unsafe fn shouldShowBannerForLocallyReceivedChallenge(
            &self,
            challenge: Option<&GKChallenge>,
        ) -> bool;

        #[cfg(feature = "GKChallenge")]
        /// Called when the local player has received a challenge, triggered by a push notification from the server. Received only while the game is running.
        ///
        /// # Safety
        ///
        /// `challenge` might not allow `None`.
        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
        #[optional]
        #[unsafe(method(localPlayerDidReceiveChallenge:))]
        #[unsafe(method_family = none)]
        unsafe fn localPlayerDidReceiveChallenge(&self, challenge: Option<&GKChallenge>);

        #[cfg(feature = "GKChallenge")]
        /// If the method returns YES, a challenge banner (like an achievement or welcome banner -- not a notification center banner) is displayed. If NO, then no banner is displayed. Default behavior for non-implementing apps is YES.
        ///
        /// # Safety
        ///
        /// `challenge` might not allow `None`.
        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
        #[optional]
        #[unsafe(method(shouldShowBannerForLocallyCompletedChallenge:))]
        #[unsafe(method_family = none)]
        unsafe fn shouldShowBannerForLocallyCompletedChallenge(
            &self,
            challenge: Option<&GKChallenge>,
        ) -> bool;

        #[cfg(feature = "GKChallenge")]
        /// Called when the local player has completed one of their challenges, triggered by a push notification from the server. Received only while the game is running.
        ///
        /// # Safety
        ///
        /// `challenge` might not allow `None`.
        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
        #[optional]
        #[unsafe(method(localPlayerDidCompleteChallenge:))]
        #[unsafe(method_family = none)]
        unsafe fn localPlayerDidCompleteChallenge(&self, challenge: Option<&GKChallenge>);

        #[cfg(feature = "GKChallenge")]
        /// If the method returns YES, a challenge banner (like an achievement or welcome banner -- not a notification center banner) is displayed. If NO, then no banner is displayed. Default behavior for non-implementing apps is YES.
        ///
        /// # Safety
        ///
        /// `challenge` might not allow `None`.
        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
        #[optional]
        #[unsafe(method(shouldShowBannerForRemotelyCompletedChallenge:))]
        #[unsafe(method_family = none)]
        unsafe fn shouldShowBannerForRemotelyCompletedChallenge(
            &self,
            challenge: Option<&GKChallenge>,
        ) -> bool;

        #[cfg(feature = "GKChallenge")]
        /// Called when a non-local player has completed a challenge issued by the local player. Triggered by a push notification from the server. Received when a challenge notification banner is tapped, or while the game is running.
        ///
        /// # Safety
        ///
        /// `challenge` might not allow `None`.
        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
        #[optional]
        #[unsafe(method(remotePlayerDidCompleteChallenge:))]
        #[unsafe(method_family = none)]
        unsafe fn remotePlayerDidCompleteChallenge(&self, challenge: Option<&GKChallenge>);
    }
);

extern_class!(
    /// A singleton object responsible for dispatching challenge-related events to its delegate
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkchallengeeventhandler?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
    pub struct GKChallengeEventHandler;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for GKChallengeEventHandler {}
);

impl GKChallengeEventHandler {
    extern_methods!(
        #[deprecated = "No longer supported."]
        #[unsafe(method(challengeEventHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn challengeEventHandler() -> Option<Retained<GKChallengeEventHandler>>;

        #[deprecated = "No longer supported."]
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn GKChallengeEventHandlerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        ///
        /// # Safety
        ///
        /// `delegate` might not allow `None`.
        #[deprecated = "No longer supported."]
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn GKChallengeEventHandlerDelegate>>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl GKChallengeEventHandler {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}