1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//! 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>;
);
}