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
24extern_conformance!(
25 unsafe impl NSObjectProtocol for CMFallDetectionManager {}
26);
27
28impl CMFallDetectionManager {
29 extern_methods!(
30 /// available
31 ///
32 /// Returns a value indicating whether the current device supports Fall Detection.
33 #[unsafe(method(isAvailable))]
34 #[unsafe(method_family = none)]
35 pub unsafe fn isAvailable() -> bool;
36
37 #[cfg(feature = "CMAuthorization")]
38 /// authorizationStatus
39 ///
40 /// Returns a value indicating whether the user has authorized the app to receive Fall Detection updates
41 #[unsafe(method(authorizationStatus))]
42 #[unsafe(method_family = none)]
43 pub unsafe fn authorizationStatus(&self) -> CMAuthorizationStatus;
44
45 /// delegate
46 ///
47 /// The delegate object to receive Fall Detection events.
48 #[unsafe(method(delegate))]
49 #[unsafe(method_family = none)]
50 pub unsafe fn delegate(
51 &self,
52 ) -> Option<Retained<ProtocolObject<dyn CMFallDetectionDelegate>>>;
53
54 /// This is a [weak property][objc2::topics::weak_property].
55 /// Setter for [`delegate`][Self::delegate].
56 #[unsafe(method(setDelegate:))]
57 #[unsafe(method_family = none)]
58 pub unsafe fn setDelegate(
59 &self,
60 delegate: Option<&ProtocolObject<dyn CMFallDetectionDelegate>>,
61 );
62
63 #[cfg(all(feature = "CMAuthorization", feature = "block2"))]
64 /// Requests the user’s permission to access Fall Detection information.
65 #[unsafe(method(requestAuthorizationWithHandler:))]
66 #[unsafe(method_family = none)]
67 pub unsafe fn requestAuthorizationWithHandler(
68 &self,
69 handler: &block2::DynBlock<dyn Fn(CMAuthorizationStatus)>,
70 );
71 );
72}
73
74/// Methods declared on superclass `NSObject`.
75impl CMFallDetectionManager {
76 extern_methods!(
77 #[unsafe(method(init))]
78 #[unsafe(method_family = init)]
79 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
80
81 #[unsafe(method(new))]
82 #[unsafe(method_family = new)]
83 pub unsafe fn new() -> Retained<Self>;
84 );
85}
86
87extern_protocol!(
88 /// CMFallDetectionDelegate
89 ///
90 ///
91 /// CMFallDetectionManager notifies its delegate about Fall Detection related information using this protocol
92 ///
93 /// See also: CMFallDetectionManager
94 ///
95 /// See also [Apple's documentation](https://developer.apple.com/documentation/coremotion/cmfalldetectiondelegate?language=objc)
96 pub unsafe trait CMFallDetectionDelegate: NSObjectProtocol {
97 #[cfg(all(feature = "CMFallDetectionEvent", feature = "block2"))]
98 /// Update the delegate with a new Fall Detection event
99 ///
100 ///
101 /// 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.
102 ///
103 ///
104 /// Fall Detection events may occur when the app is not running.
105 /// 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.
106 /// 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.
107 ///
108 /// 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.
109 ///
110 /// The same event may be reported across different app launches, always check the date of the event before processing it.
111 ///
112 /// Fall Detection events can be simulated with the watchOS simulator. Use it to test the background functionality of your app.
113 #[optional]
114 #[unsafe(method(fallDetectionManager:didDetectEvent:completionHandler:))]
115 #[unsafe(method_family = none)]
116 unsafe fn fallDetectionManager_didDetectEvent_completionHandler(
117 &self,
118 fall_detection_manager: &CMFallDetectionManager,
119 event: &CMFallDetectionEvent,
120 handler: &block2::DynBlock<dyn Fn()>,
121 );
122
123 /// Update the delegate when the app's Fall Detection authorization status changes
124 #[optional]
125 #[unsafe(method(fallDetectionManagerDidChangeAuthorization:))]
126 #[unsafe(method_family = none)]
127 unsafe fn fallDetectionManagerDidChangeAuthorization(
128 &self,
129 fall_detection_manager: &CMFallDetectionManager,
130 );
131 }
132);