rust_macios/user_notifications/
un_notification_settings.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 object,
5 objective_c_runtime::{macros::interface_impl, traits::PNSObject},
6 utils::to_bool,
7};
8
9object! {
10 unsafe pub struct UNNotificationSettings;
12}
13
14#[repr(i64)]
16#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
17pub enum UNAuthorizationStatus {
18 NotDetermined = 0,
20 Denied,
22 Authorized,
24 #[cfg(target_os = "ios")]
26 Provisional,
27 #[cfg(target_os = "ios")]
29 Ephemeral,
30}
31
32#[repr(i64)]
34#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
35pub enum UNNotificationSetting {
36 NotSupported = 0,
38 Disabled,
40 Enabled,
42}
43
44#[repr(i64)]
46#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
47pub enum UNAlertStyle {
48 None = 0,
50 Banner,
52 Alert,
54}
55
56#[repr(i64)]
58#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
59pub enum UNShowPreviewsSetting {
60 Always,
62 WhenAuthenticated,
64 Never,
66}
67
68#[interface_impl(NSObject)]
69impl UNNotificationSettings {
70 #[property]
75 pub fn authorization_status(&self) -> UNAuthorizationStatus {
76 unsafe { msg_send![self.m_self(), authorizationStatus] }
77 }
78
79 #[property]
84 pub fn notification_center_setting(&self) -> UNNotificationSetting {
85 unsafe { msg_send![self.m_self(), notificationCenterSetting] }
86 }
87
88 #[property]
90 pub fn lock_screen_setting(&self) -> UNNotificationSetting {
91 unsafe { msg_send![self.m_self(), lockScreenSetting] }
92 }
93
94 #[property]
96 pub fn car_play_setting(&self) -> UNNotificationSetting {
97 unsafe { msg_send![self.m_self(), carPlaySetting] }
98 }
99
100 #[property]
102 pub fn alert_setting(&self) -> UNNotificationSetting {
103 unsafe { msg_send![self.m_self(), alertSetting] }
104 }
105
106 #[property]
108 pub fn badge_setting(&self) -> UNNotificationSetting {
109 unsafe { msg_send![self.m_self(), badgeSetting] }
110 }
111
112 #[property]
114 pub fn sound_setting(&self) -> UNNotificationSetting {
115 unsafe { msg_send![self.m_self(), soundSetting] }
116 }
117
118 #[property]
120 pub fn critical_alert_setting(&self) -> UNNotificationSetting {
121 unsafe { msg_send![self.m_self(), criticalAlertSetting] }
122 }
123
124 #[property]
126 pub fn announcement_setting(&self) -> UNNotificationSetting {
127 unsafe { msg_send![self.m_self(), announcementSetting] }
128 }
129
130 #[property]
132 pub fn scheduled_delivery_setting(&self) -> UNNotificationSetting {
133 unsafe { msg_send![self.m_self(), scheduledDeliverySetting] }
134 }
135
136 #[property]
138 pub fn time_sensitive_setting(&self) -> UNNotificationSetting {
139 unsafe { msg_send![self.m_self(), timeSensitiveSetting] }
140 }
141
142 #[property]
147 pub fn show_previews_setting(&self) -> UNShowPreviewsSetting {
148 unsafe { msg_send![self.m_self(), showPreviewsSetting] }
149 }
150
151 #[property]
153 pub fn provides_app_notification_settings(&self) -> bool {
154 unsafe { to_bool(msg_send![self.m_self(), providesAppNotificationSettings]) }
155 }
156
157 #[property]
159 pub fn direct_messages_setting(&self) -> UNNotificationSetting {
160 unsafe { msg_send![self.m_self(), directMessagesSetting] }
161 }
162}