objc2_game_kit/generated/
GKChallengeEventHandler.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_protocol!(
10    /// 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.
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkchallengeeventhandlerdelegate?language=objc)
13    #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
14    pub unsafe trait GKChallengeEventHandlerDelegate: NSObjectProtocol {
15        #[cfg(feature = "GKChallenge")]
16        /// 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.
17        ///
18        /// # Safety
19        ///
20        /// `challenge` might not allow `None`.
21        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
22        #[optional]
23        #[unsafe(method(localPlayerDidSelectChallenge:))]
24        #[unsafe(method_family = none)]
25        unsafe fn localPlayerDidSelectChallenge(&self, challenge: Option<&GKChallenge>);
26
27        #[cfg(feature = "GKChallenge")]
28        /// 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.
29        ///
30        /// # Safety
31        ///
32        /// `challenge` might not allow `None`.
33        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
34        #[optional]
35        #[unsafe(method(shouldShowBannerForLocallyReceivedChallenge:))]
36        #[unsafe(method_family = none)]
37        unsafe fn shouldShowBannerForLocallyReceivedChallenge(
38            &self,
39            challenge: Option<&GKChallenge>,
40        ) -> bool;
41
42        #[cfg(feature = "GKChallenge")]
43        /// Called when the local player has received a challenge, triggered by a push notification from the server. Received only while the game is running.
44        ///
45        /// # Safety
46        ///
47        /// `challenge` might not allow `None`.
48        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
49        #[optional]
50        #[unsafe(method(localPlayerDidReceiveChallenge:))]
51        #[unsafe(method_family = none)]
52        unsafe fn localPlayerDidReceiveChallenge(&self, challenge: Option<&GKChallenge>);
53
54        #[cfg(feature = "GKChallenge")]
55        /// 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.
56        ///
57        /// # Safety
58        ///
59        /// `challenge` might not allow `None`.
60        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
61        #[optional]
62        #[unsafe(method(shouldShowBannerForLocallyCompletedChallenge:))]
63        #[unsafe(method_family = none)]
64        unsafe fn shouldShowBannerForLocallyCompletedChallenge(
65            &self,
66            challenge: Option<&GKChallenge>,
67        ) -> bool;
68
69        #[cfg(feature = "GKChallenge")]
70        /// 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.
71        ///
72        /// # Safety
73        ///
74        /// `challenge` might not allow `None`.
75        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
76        #[optional]
77        #[unsafe(method(localPlayerDidCompleteChallenge:))]
78        #[unsafe(method_family = none)]
79        unsafe fn localPlayerDidCompleteChallenge(&self, challenge: Option<&GKChallenge>);
80
81        #[cfg(feature = "GKChallenge")]
82        /// 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.
83        ///
84        /// # Safety
85        ///
86        /// `challenge` might not allow `None`.
87        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
88        #[optional]
89        #[unsafe(method(shouldShowBannerForRemotelyCompletedChallenge:))]
90        #[unsafe(method_family = none)]
91        unsafe fn shouldShowBannerForRemotelyCompletedChallenge(
92            &self,
93            challenge: Option<&GKChallenge>,
94        ) -> bool;
95
96        #[cfg(feature = "GKChallenge")]
97        /// 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.
98        ///
99        /// # Safety
100        ///
101        /// `challenge` might not allow `None`.
102        #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
103        #[optional]
104        #[unsafe(method(remotePlayerDidCompleteChallenge:))]
105        #[unsafe(method_family = none)]
106        unsafe fn remotePlayerDidCompleteChallenge(&self, challenge: Option<&GKChallenge>);
107    }
108);
109
110extern_class!(
111    /// A singleton object responsible for dispatching challenge-related events to its delegate
112    ///
113    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkchallengeeventhandler?language=objc)
114    #[unsafe(super(NSObject))]
115    #[derive(Debug, PartialEq, Eq, Hash)]
116    #[deprecated = "You should instead implement the GKChallengeListener protocol and register a listener with GKLocalPlayer."]
117    pub struct GKChallengeEventHandler;
118);
119
120extern_conformance!(
121    unsafe impl NSObjectProtocol for GKChallengeEventHandler {}
122);
123
124impl GKChallengeEventHandler {
125    extern_methods!(
126        #[deprecated = "No longer supported."]
127        #[unsafe(method(challengeEventHandler))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn challengeEventHandler() -> Option<Retained<GKChallengeEventHandler>>;
130
131        #[deprecated = "No longer supported."]
132        #[unsafe(method(delegate))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn delegate(
135            &self,
136        ) -> Option<Retained<ProtocolObject<dyn GKChallengeEventHandlerDelegate>>>;
137
138        /// Setter for [`delegate`][Self::delegate].
139        ///
140        /// This is a [weak property][objc2::topics::weak_property].
141        ///
142        /// # Safety
143        ///
144        /// `delegate` might not allow `None`.
145        #[deprecated = "No longer supported."]
146        #[unsafe(method(setDelegate:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn setDelegate(
149            &self,
150            delegate: Option<&ProtocolObject<dyn GKChallengeEventHandlerDelegate>>,
151        );
152    );
153}
154
155/// Methods declared on superclass `NSObject`.
156impl GKChallengeEventHandler {
157    extern_methods!(
158        #[unsafe(method(init))]
159        #[unsafe(method_family = init)]
160        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
161
162        #[unsafe(method(new))]
163        #[unsafe(method_family = new)]
164        pub unsafe fn new() -> Retained<Self>;
165    );
166}