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        /// # Safety
250        ///
251        /// `user_info` generic should be of the correct type.
252        #[optional]
253        #[unsafe(method(handleUserActivity:))]
254        #[unsafe(method_family = none)]
255        unsafe fn handleUserActivity(&self, user_info: Option<&NSDictionary>);
256
257        #[optional]
258        #[unsafe(method(handleActivity:))]
259        #[unsafe(method_family = none)]
260        unsafe fn handleActivity(&self, user_activity: &NSUserActivity);
261
262        #[cfg(all(feature = "block2", feature = "objc2-intents"))]
263        #[optional]
264        #[unsafe(method(handleIntent:completionHandler:))]
265        #[unsafe(method_family = none)]
266        unsafe fn handleIntent_completionHandler(
267            &self,
268            intent: &INIntent,
269            completion_handler: &block2::DynBlock<dyn Fn(NonNull<INIntentResponse>)>,
270        );
271
272        #[cfg(feature = "WKBackgroundTask")]
273        #[optional]
274        #[unsafe(method(handleBackgroundTasks:))]
275        #[unsafe(method_family = none)]
276        unsafe fn handleBackgroundTasks(&self, background_tasks: &NSSet<WKRefreshBackgroundTask>);
277
278        #[optional]
279        #[unsafe(method(deviceOrientationDidChange))]
280        #[unsafe(method_family = none)]
281        unsafe fn deviceOrientationDidChange(&self);
282
283        #[optional]
284        #[unsafe(method(didRegisterForRemoteNotificationsWithDeviceToken:))]
285        #[unsafe(method_family = none)]
286        unsafe fn didRegisterForRemoteNotificationsWithDeviceToken(&self, device_token: &NSData);
287
288        #[optional]
289        #[unsafe(method(didFailToRegisterForRemoteNotificationsWithError:))]
290        #[unsafe(method_family = none)]
291        unsafe fn didFailToRegisterForRemoteNotificationsWithError(&self, error: &NSError);
292
293        #[cfg(feature = "block2")]
294        /// 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.
295        ///
296        /// This method will be invoked even if the application was launched or resumed because of the remote background notification.!
297        ///
298        /// # Safety
299        ///
300        /// `user_info` generic should be of the correct type.
301        #[optional]
302        #[unsafe(method(didReceiveRemoteNotification:fetchCompletionHandler:))]
303        #[unsafe(method_family = none)]
304        unsafe fn didReceiveRemoteNotification_fetchCompletionHandler(
305            &self,
306            user_info: &NSDictionary,
307            completion_handler: &block2::DynBlock<dyn Fn(WKBackgroundFetchResult)>,
308        );
309
310        #[cfg(feature = "objc2-cloud-kit")]
311        #[optional]
312        #[unsafe(method(userDidAcceptCloudKitShareWithMetadata:))]
313        #[unsafe(method_family = none)]
314        unsafe fn userDidAcceptCloudKitShareWithMetadata(
315            &self,
316            cloud_kit_share_metadata: &CKShareMetadata,
317        );
318
319        /// # Safety
320        ///
321        /// `remote_notification` generic should be of the correct type.
322        #[deprecated = "use UNUserNotificationCenterDelegate"]
323        #[optional]
324        #[unsafe(method(handleActionWithIdentifier:forRemoteNotification:))]
325        #[unsafe(method_family = none)]
326        unsafe fn handleActionWithIdentifier_forRemoteNotification(
327            &self,
328            identifier: Option<&NSString>,
329            remote_notification: &NSDictionary,
330        );
331
332        #[cfg(feature = "objc2-ui-kit")]
333        #[deprecated = "use UNUserNotificationCenterDelegate"]
334        #[optional]
335        #[unsafe(method(handleActionWithIdentifier:forLocalNotification:))]
336        #[unsafe(method_family = none)]
337        unsafe fn handleActionWithIdentifier_forLocalNotification(
338            &self,
339            identifier: Option<&NSString>,
340            local_notification: &UILocalNotification,
341        );
342
343        /// # Safety
344        ///
345        /// - `remote_notification` generic should be of the correct type.
346        /// - `response_info` generic should be of the correct type.
347        #[deprecated = "use UNUserNotificationCenterDelegate"]
348        #[optional]
349        #[unsafe(method(handleActionWithIdentifier:forRemoteNotification:withResponseInfo:))]
350        #[unsafe(method_family = none)]
351        unsafe fn handleActionWithIdentifier_forRemoteNotification_withResponseInfo(
352            &self,
353            identifier: Option<&NSString>,
354            remote_notification: &NSDictionary,
355            response_info: &NSDictionary,
356        );
357
358        #[cfg(feature = "objc2-ui-kit")]
359        /// # Safety
360        ///
361        /// `response_info` generic should be of the correct type.
362        #[deprecated = "use UNUserNotificationCenterDelegate"]
363        #[optional]
364        #[unsafe(method(handleActionWithIdentifier:forLocalNotification:withResponseInfo:))]
365        #[unsafe(method_family = none)]
366        unsafe fn handleActionWithIdentifier_forLocalNotification_withResponseInfo(
367            &self,
368            identifier: Option<&NSString>,
369            local_notification: &UILocalNotification,
370            response_info: &NSDictionary,
371        );
372
373        /// # Safety
374        ///
375        /// `user_info` generic should be of the correct type.
376        #[deprecated = "use UNUserNotificationCenterDelegate"]
377        #[optional]
378        #[unsafe(method(didReceiveRemoteNotification:))]
379        #[unsafe(method_family = none)]
380        unsafe fn didReceiveRemoteNotification(&self, user_info: &NSDictionary);
381
382        #[cfg(feature = "objc2-ui-kit")]
383        #[deprecated = "use UNUserNotificationCenterDelegate"]
384        #[optional]
385        #[unsafe(method(didReceiveLocalNotification:))]
386        #[unsafe(method_family = none)]
387        unsafe fn didReceiveLocalNotification(&self, notification: &UILocalNotification);
388    }
389);