objc2_core_motion/generated/
CMFallDetectionManager.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_class!(
10    /// CMFallDetectionManager
11    ///
12    ///
13    /// Use CMFallDetectionManager to receive information about Fall Detection events. Not all watch models support Fall Detection, check for availability before creating an instance of CMFallDetectionManager.
14    /// CMFallDetectionManager requires an entitlement from Apple. To apply for the entitlement, see Fall Detection Entitlement Request.
15    ///
16    /// Set the delegate immediately after creating an instance of CMFallDetectionManager. Creating multiple instances of CMFallDetectionManager is not supported and should be avoided.
17    ///
18    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmfalldetectionmanager?language=objc)
19    #[unsafe(super(NSObject))]
20    #[derive(Debug, PartialEq, Eq, Hash)]
21    pub struct CMFallDetectionManager;
22);
23
24unsafe impl NSObjectProtocol for CMFallDetectionManager {}
25
26impl CMFallDetectionManager {
27    extern_methods!(
28        /// available
29        ///
30        /// Returns a  value indicating whether the current device supports Fall Detection.
31        #[unsafe(method(isAvailable))]
32        #[unsafe(method_family = none)]
33        pub unsafe fn isAvailable() -> bool;
34
35        #[cfg(feature = "CMAuthorization")]
36        /// authorizationStatus
37        ///
38        /// Returns a value indicating whether the user has authorized the app to receive Fall Detection updates
39        #[unsafe(method(authorizationStatus))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn authorizationStatus(&self) -> CMAuthorizationStatus;
42
43        /// delegate
44        ///
45        /// The delegate object to receive Fall Detection events.
46        #[unsafe(method(delegate))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn delegate(
49            &self,
50        ) -> Option<Retained<ProtocolObject<dyn CMFallDetectionDelegate>>>;
51
52        /// This is a [weak property][objc2::topics::weak_property].
53        /// Setter for [`delegate`][Self::delegate].
54        #[unsafe(method(setDelegate:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn setDelegate(
57            &self,
58            delegate: Option<&ProtocolObject<dyn CMFallDetectionDelegate>>,
59        );
60
61        #[cfg(all(feature = "CMAuthorization", feature = "block2"))]
62        /// Requests the user’s permission to access Fall Detection information.
63        #[unsafe(method(requestAuthorizationWithHandler:))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn requestAuthorizationWithHandler(
66            &self,
67            handler: &block2::Block<dyn Fn(CMAuthorizationStatus)>,
68        );
69    );
70}
71
72/// Methods declared on superclass `NSObject`.
73impl CMFallDetectionManager {
74    extern_methods!(
75        #[unsafe(method(init))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
78
79        #[unsafe(method(new))]
80        #[unsafe(method_family = new)]
81        pub unsafe fn new() -> Retained<Self>;
82    );
83}
84
85extern_protocol!(
86    /// CMFallDetectionDelegate
87    ///
88    ///
89    /// CMFallDetectionManager notifies its delegate about Fall Detection related information using this protocol
90    ///
91    /// See also: CMFallDetectionManager
92    ///
93    /// See also [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmfalldetectiondelegate?language=objc)
94    pub unsafe trait CMFallDetectionDelegate: NSObjectProtocol {
95        #[cfg(all(feature = "CMFallDetectionEvent", feature = "block2"))]
96        /// Update the delegate with a new Fall Detection event
97        ///
98        ///
99        /// Parameter `handler`: Apps running in the background have a finite amount of time to process Fall Detection events. Call this handler to indicate that the app has finished handling the event. The system may suspend or terminate the app before calling this block.
100        ///
101        ///
102        /// Fall Detection events may occur when the app is not running.
103        /// Following a Fall Detection event, the system will launch the watchOS app in the background giving it small amount of background execution time. This time should be used for critical tasks related to the Fall Event. For example: placing a network request or scheduling a local notification.
104        /// In order to receive Fall Detection events, create a new CMFallDetectionManager instance and set its delegate early in the watchOS app lifecycle (applicationDidFinishLaunching for example). Note that instances of WKInterfaceController may not be created when launched in the background.
105        ///
106        /// If multiple Fall Detection events are generated while the app is not running, only the most recent event will be reported on the next app launch.
107        ///
108        /// The same event may be reported across different app launches, always check the date of the event before processing it.
109        ///
110        /// Fall Detection events can be simulated with the watchOS simulator. Use it to test the background functionality of your app.
111        #[optional]
112        #[unsafe(method(fallDetectionManager:didDetectEvent:completionHandler:))]
113        #[unsafe(method_family = none)]
114        unsafe fn fallDetectionManager_didDetectEvent_completionHandler(
115            &self,
116            fall_detection_manager: &CMFallDetectionManager,
117            event: &CMFallDetectionEvent,
118            handler: &block2::Block<dyn Fn()>,
119        );
120
121        /// Update the delegate when the app's Fall Detection authorization status changes
122        #[optional]
123        #[unsafe(method(fallDetectionManagerDidChangeAuthorization:))]
124        #[unsafe(method_family = none)]
125        unsafe fn fallDetectionManagerDidChangeAuthorization(
126            &self,
127            fall_detection_manager: &CMFallDetectionManager,
128        );
129    }
130);