objc2_watch_kit/generated/
WKExtension.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#[cfg(feature = "objc2-cloud-kit")]
7use objc2_cloud_kit::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-health-kit")]
10use objc2_health_kit::*;
11#[cfg(feature = "objc2-intents")]
12use objc2_intents::*;
13#[cfg(feature = "objc2-ui-kit")]
14use objc2_ui_kit::*;
15
16use crate::*;
17
18/// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationstate?language=objc)
19// NS_ENUM
20#[repr(transparent)]
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct WKApplicationState(pub NSInteger);
23impl WKApplicationState {
24    #[doc(alias = "WKApplicationStateActive")]
25    pub const Active: Self = Self(0);
26    #[doc(alias = "WKApplicationStateInactive")]
27    pub const Inactive: Self = Self(1);
28    #[doc(alias = "WKApplicationStateBackground")]
29    pub const Background: Self = Self(2);
30}
31
32unsafe impl Encode for WKApplicationState {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for WKApplicationState {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40/// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkbackgroundfetchresult?language=objc)
41// NS_ENUM
42#[repr(transparent)]
43#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44pub struct WKBackgroundFetchResult(pub NSUInteger);
45impl WKBackgroundFetchResult {
46    #[doc(alias = "WKBackgroundFetchResultNewData")]
47    pub const NewData: Self = Self(0);
48    #[doc(alias = "WKBackgroundFetchResultNoData")]
49    pub const NoData: Self = Self(1);
50    #[doc(alias = "WKBackgroundFetchResultFailed")]
51    pub const Failed: Self = Self(2);
52}
53
54unsafe impl Encode for WKBackgroundFetchResult {
55    const ENCODING: Encoding = NSUInteger::ENCODING;
56}
57
58unsafe impl RefEncode for WKBackgroundFetchResult {
59    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
60}
61
62extern_class!(
63    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkextension?language=objc)
64    #[unsafe(super(NSObject))]
65    #[thread_kind = MainThreadOnly]
66    #[derive(Debug, PartialEq, Eq, Hash)]
67    pub struct WKExtension;
68);
69
70extern_conformance!(
71    unsafe impl NSObjectProtocol for WKExtension {}
72);
73
74impl WKExtension {
75    extern_methods!(
76        #[unsafe(method(sharedExtension))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn sharedExtension(mtm: MainThreadMarker) -> Retained<WKExtension>;
79
80        #[unsafe(method(init))]
81        #[unsafe(method_family = init)]
82        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
83
84        #[unsafe(method(new))]
85        #[unsafe(method_family = new)]
86        pub unsafe fn new(&self) -> Retained<Self>;
87
88        #[unsafe(method(openSystemURL:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn openSystemURL(&self, url: &NSURL);
91
92        #[unsafe(method(delegate))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn WKExtensionDelegate>>>;
95
96        #[cfg(feature = "WKInterfaceController")]
97        #[unsafe(method(rootInterfaceController))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn rootInterfaceController(&self) -> Option<Retained<WKInterfaceController>>;
100
101        #[cfg(feature = "WKInterfaceController")]
102        #[unsafe(method(visibleInterfaceController))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn visibleInterfaceController(&self) -> Option<Retained<WKInterfaceController>>;
105
106        #[unsafe(method(applicationState))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn applicationState(&self) -> WKApplicationState;
109
110        #[unsafe(method(isApplicationRunningInDock))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn isApplicationRunningInDock(&self) -> bool;
113
114        #[unsafe(method(isAutorotating))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn isAutorotating(&self) -> bool;
117
118        /// Setter for [`isAutorotating`][Self::isAutorotating].
119        #[unsafe(method(setAutorotating:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn setAutorotating(&self, autorotating: bool);
122
123        #[unsafe(method(isAutorotated))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn isAutorotated(&self) -> bool;
126
127        #[deprecated = "No longer supported"]
128        #[unsafe(method(isFrontmostTimeoutExtended))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn isFrontmostTimeoutExtended(&self) -> bool;
131
132        /// Setter for [`isFrontmostTimeoutExtended`][Self::isFrontmostTimeoutExtended].
133        #[deprecated = "No longer supported"]
134        #[unsafe(method(setFrontmostTimeoutExtended:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn setFrontmostTimeoutExtended(&self, frontmost_timeout_extended: bool);
137
138        #[deprecated]
139        #[unsafe(method(enableWaterLock))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn enableWaterLock(&self);
142
143        #[unsafe(method(registerForRemoteNotifications))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn registerForRemoteNotifications(&self);
146
147        #[unsafe(method(unregisterForRemoteNotifications))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn unregisterForRemoteNotifications(&self);
150
151        #[unsafe(method(isRegisteredForRemoteNotifications))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn isRegisteredForRemoteNotifications(&self) -> bool;
154
155        #[cfg(feature = "objc2-ui-kit")]
156        #[unsafe(method(globalTintColor))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn globalTintColor(&self) -> Retained<UIColor>;
159    );
160}
161
162/// Methods declared on superclass `NSObject`.
163impl WKExtension {
164    extern_methods!(
165        #[unsafe(method(new))]
166        #[unsafe(method_family = new)]
167        pub unsafe fn new_class(mtm: MainThreadMarker) -> Retained<Self>;
168    );
169}
170
171extern "C" {
172    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationdidfinishlaunchingnotification?language=objc)
173    pub static WKApplicationDidFinishLaunchingNotification: &'static NSNotificationName;
174}
175
176extern "C" {
177    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationdidbecomeactivenotification?language=objc)
178    pub static WKApplicationDidBecomeActiveNotification: &'static NSNotificationName;
179}
180
181extern "C" {
182    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationwillresignactivenotification?language=objc)
183    pub static WKApplicationWillResignActiveNotification: &'static NSNotificationName;
184}
185
186extern "C" {
187    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationwillenterforegroundnotification?language=objc)
188    pub static WKApplicationWillEnterForegroundNotification: &'static NSNotificationName;
189}
190
191extern "C" {
192    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkapplicationdidenterbackgroundnotification?language=objc)
193    pub static WKApplicationDidEnterBackgroundNotification: &'static NSNotificationName;
194}
195
196extern_protocol!(
197    /// [Apple's documentation](https://developer.apple.com/documentation/watchkit/wkextensiondelegate?language=objc)
198    pub unsafe trait WKExtensionDelegate: NSObjectProtocol + MainThreadOnly {
199        #[optional]
200        #[unsafe(method(applicationDidFinishLaunching))]
201        #[unsafe(method_family = none)]
202        unsafe fn applicationDidFinishLaunching(&self);
203
204        #[optional]
205        #[unsafe(method(applicationDidBecomeActive))]
206        #[unsafe(method_family = none)]
207        unsafe fn applicationDidBecomeActive(&self);
208
209        #[optional]
210        #[unsafe(method(applicationWillResignActive))]
211        #[unsafe(method_family = none)]
212        unsafe fn applicationWillResignActive(&self);
213
214        #[optional]
215        #[unsafe(method(applicationWillEnterForeground))]
216        #[unsafe(method_family = none)]
217        unsafe fn applicationWillEnterForeground(&self);
218
219        #[optional]
220        #[unsafe(method(applicationDidEnterBackground))]
221        #[unsafe(method_family = none)]
222        unsafe fn applicationDidEnterBackground(&self);
223
224        #[cfg(feature = "objc2-health-kit")]
225        #[optional]
226        #[unsafe(method(handleWorkoutConfiguration:))]
227        #[unsafe(method_family = none)]
228        unsafe fn handleWorkoutConfiguration(&self, workout_configuration: &HKWorkoutConfiguration);
229
230        #[optional]
231        #[unsafe(method(handleActiveWorkoutRecovery))]
232        #[unsafe(method_family = none)]
233        unsafe fn handleActiveWorkoutRecovery(&self);
234
235        #[cfg(feature = "WKExtendedRuntimeSession")]
236        #[optional]
237        #[unsafe(method(handleExtendedRuntimeSession:))]
238        #[unsafe(method_family = none)]
239        unsafe fn handleExtendedRuntimeSession(
240            &self,
241            extended_runtime_session: &WKExtendedRuntimeSession,
242        );
243
244        #[optional]
245        #[unsafe(method(handleRemoteNowPlayingActivity))]
246        #[unsafe(method_family = none)]
247        unsafe fn handleRemoteNowPlayingActivity(&self);
248
249        #[optional]
250        #[unsafe(method(handleUserActivity:))]
251        #[unsafe(method_family = none)]
252        unsafe fn handleUserActivity(&self, user_info: Option<&NSDictionary>);
253
254        #[optional]
255        #[unsafe(method(handleActivity:))]
256        #[unsafe(method_family = none)]
257        unsafe fn handleActivity(&self, user_activity: &NSUserActivity);
258
259        #[cfg(all(feature = "block2", feature = "objc2-intents"))]
260        #[optional]
261        #[unsafe(method(handleIntent:completionHandler:))]
262        #[unsafe(method_family = none)]
263        unsafe fn handleIntent_completionHandler(
264            &self,
265            intent: &INIntent,
266            completion_handler: &block2::DynBlock<dyn Fn(NonNull<INIntentResponse>)>,
267        );
268
269        #[cfg(feature = "WKBackgroundTask")]
270        #[optional]
271        #[unsafe(method(handleBackgroundTasks:))]
272        #[unsafe(method_family = none)]
273        unsafe fn handleBackgroundTasks(&self, background_tasks: &NSSet<WKRefreshBackgroundTask>);
274
275        #[optional]
276        #[unsafe(method(deviceOrientationDidChange))]
277        #[unsafe(method_family = none)]
278        unsafe fn deviceOrientationDidChange(&self);
279
280        #[optional]
281        #[unsafe(method(didRegisterForRemoteNotificationsWithDeviceToken:))]
282        #[unsafe(method_family = none)]
283        unsafe fn didRegisterForRemoteNotificationsWithDeviceToken(&self, device_token: &NSData);
284
285        #[optional]
286        #[unsafe(method(didFailToRegisterForRemoteNotificationsWithError:))]
287        #[unsafe(method_family = none)]
288        unsafe fn didFailToRegisterForRemoteNotificationsWithError(&self, error: &NSError);
289
290        #[cfg(feature = "block2")]
291        /// This delegate method offers an opportunity for applications with the "remote-notification" background mode to fetch appropriate new data in response to an incoming remote notification. You should call the fetchCompletionHandler as soon as you're finished performing that operation, so the system can accurately estimate its power and data cost.
292        ///
293        /// This method will be invoked even if the application was launched or resumed because of the remote background notification.!
294        #[optional]
295        #[unsafe(method(didReceiveRemoteNotification:fetchCompletionHandler:))]
296        #[unsafe(method_family = none)]
297        unsafe fn didReceiveRemoteNotification_fetchCompletionHandler(
298            &self,
299            user_info: &NSDictionary,
300            completion_handler: &block2::DynBlock<dyn Fn(WKBackgroundFetchResult)>,
301        );
302
303        #[cfg(feature = "objc2-cloud-kit")]
304        #[optional]
305        #[unsafe(method(userDidAcceptCloudKitShareWithMetadata:))]
306        #[unsafe(method_family = none)]
307        unsafe fn userDidAcceptCloudKitShareWithMetadata(
308            &self,
309            cloud_kit_share_metadata: &CKShareMetadata,
310        );
311
312        #[deprecated = "use UNUserNotificationCenterDelegate"]
313        #[optional]
314        #[unsafe(method(handleActionWithIdentifier:forRemoteNotification:))]
315        #[unsafe(method_family = none)]
316        unsafe fn handleActionWithIdentifier_forRemoteNotification(
317            &self,
318            identifier: Option<&NSString>,
319            remote_notification: &NSDictionary,
320        );
321
322        #[cfg(feature = "objc2-ui-kit")]
323        #[deprecated = "use UNUserNotificationCenterDelegate"]
324        #[optional]
325        #[unsafe(method(handleActionWithIdentifier:forLocalNotification:))]
326        #[unsafe(method_family = none)]
327        unsafe fn handleActionWithIdentifier_forLocalNotification(
328            &self,
329            identifier: Option<&NSString>,
330            local_notification: &UILocalNotification,
331        );
332
333        #[deprecated = "use UNUserNotificationCenterDelegate"]
334        #[optional]
335        #[unsafe(method(handleActionWithIdentifier:forRemoteNotification:withResponseInfo:))]
336        #[unsafe(method_family = none)]
337        unsafe fn handleActionWithIdentifier_forRemoteNotification_withResponseInfo(
338            &self,
339            identifier: Option<&NSString>,
340            remote_notification: &NSDictionary,
341            response_info: &NSDictionary,
342        );
343
344        #[cfg(feature = "objc2-ui-kit")]
345        #[deprecated = "use UNUserNotificationCenterDelegate"]
346        #[optional]
347        #[unsafe(method(handleActionWithIdentifier:forLocalNotification:withResponseInfo:))]
348        #[unsafe(method_family = none)]
349        unsafe fn handleActionWithIdentifier_forLocalNotification_withResponseInfo(
350            &self,
351            identifier: Option<&NSString>,
352            local_notification: &UILocalNotification,
353            response_info: &NSDictionary,
354        );
355
356        #[deprecated = "use UNUserNotificationCenterDelegate"]
357        #[optional]
358        #[unsafe(method(didReceiveRemoteNotification:))]
359        #[unsafe(method_family = none)]
360        unsafe fn didReceiveRemoteNotification(&self, user_info: &NSDictionary);
361
362        #[cfg(feature = "objc2-ui-kit")]
363        #[deprecated = "use UNUserNotificationCenterDelegate"]
364        #[optional]
365        #[unsafe(method(didReceiveLocalNotification:))]
366        #[unsafe(method_family = none)]
367        unsafe fn didReceiveLocalNotification(&self, notification: &UILocalNotification);
368    }
369);