rust_macios/user_notifications/
un_notification_response.rs

1use objc::{msg_send, sel, sel_impl};
2use rust_macios_objective_c_runtime_proc_macros::interface_impl;
3
4use crate::{
5    foundation::NSString,
6    object,
7    objective_c_runtime::traits::{FromId, PNSObject},
8    uikit::UIScene,
9    utils::to_optional,
10};
11
12use super::UNNotification;
13
14object! {
15    /// The user’s response to an actionable notification.
16    unsafe pub struct UNNotificationResponse;
17}
18
19#[interface_impl(NSObject)]
20impl UNNotificationResponse {
21    /// The identifier string of the action that the user selected.
22    #[property]
23    pub fn action_identifier(&self) -> NSString {
24        unsafe { NSString::from_id(msg_send![self.m_self(), actionIdentifier]) }
25    }
26
27    /// The notification to which the user responded.
28    #[property]
29    pub fn notification(&self) -> UNNotification {
30        unsafe { UNNotification::from_id(msg_send![self.m_self(), notification]) }
31    }
32
33    /// The scene where the system reflects the user’s response to a notification.
34    ///
35    ///
36    /// Required features: `"uikit"`
37    #[property]
38    pub fn target_scene(&self) -> Option<UIScene> {
39        unsafe { to_optional(msg_send![self.m_self(), targetScene]) }
40    }
41}