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