rust_macios/user_notifications/
un_mutable_notification_content.rs

1use libc::c_double;
2use objc::{msg_send, sel, sel_impl};
3use rust_macios_objective_c_runtime_proc_macros::interface_impl;
4
5use crate::{
6    foundation::{NSArray, NSDictionary, NSNumber, NSString, UInt},
7    object,
8    objective_c_runtime::id,
9};
10
11use super::{
12    IUNNotificationContent, UNNotificationAttachment, UNNotificationInterruptionLevel,
13    UNNotificationSound,
14};
15
16object! {
17    /// The editable content for a notification.
18    unsafe pub struct UNMutableNotificationContent;
19}
20
21impl IUNNotificationContent for UNMutableNotificationContent {}
22
23#[interface_impl(UNNotificationContent)]
24impl UNMutableNotificationContent {
25    /* Providing the primary content
26     */
27    /// The localized text that provides the notification’s primary description.
28    #[property]
29    pub fn set_title(&mut self, title: NSString) {
30        unsafe { msg_send![self.m_self(), setTitle: title] }
31    }
32
33    /// The localized text that provides the notification’s secondary description.
34    #[property]
35    pub fn set_subtitle(&mut self, subtitle: NSString) {
36        unsafe { msg_send![self.m_self(), setSubtitle: subtitle] }
37    }
38
39    /// The localized text that provides the notification’s main content.
40    #[property]
41    pub fn set_body(&mut self, body: NSString) {
42        unsafe { msg_send![self.m_self(), setBody: body] }
43    }
44
45    /* Providing supplementary content
46     */
47
48    /// The visual and audio attachments to display alongside the notification’s main content.
49    #[property]
50    pub fn set_attachments(&mut self, attachments: NSArray<UNNotificationAttachment>) {
51        unsafe { msg_send![self.m_self(), setAttachments: attachments] }
52    }
53
54    /// The custom data to associate with the notification.
55    #[property]
56    pub fn set_user_info(&mut self, user_info: NSDictionary<id, id>) {
57        unsafe { msg_send![self.m_self(), setUserInfo: user_info] }
58    }
59
60    /* Configuring app behavior
61     */
62
63    /// The name of the image or storyboard to use when your app launches because of the notification.
64    #[property]
65    pub fn set_launch_image_name(&mut self, value: NSString) {
66        unsafe { msg_send![self.m_self(), setLaunchImageName: value] }
67    }
68
69    /// The number that your app’s icon displays.
70    #[property]
71    pub fn set_badge(&mut self, badge: NSNumber) {
72        unsafe { msg_send![self.m_self(), setBadge: badge] }
73    }
74
75    /// The value your app uses to determine which scene to display to handle the notification.
76    #[property]
77    pub fn set_target_content_identifier(&mut self, value: NSString) {
78        unsafe { msg_send![self.m_self(), setTargetContentIdentifier: value] }
79    }
80
81    /* Integrating with the system
82     */
83
84    /// The sound that plays when the system delivers the notification.
85    #[property]
86    pub fn set_sound(&mut self, value: UNNotificationSound) {
87        unsafe { msg_send![self.m_self(), setSound: value] }
88    }
89
90    /// The notification’s importance and required delivery timing.
91    #[property]
92    pub fn set_interruption_level(&mut self, value: UNNotificationInterruptionLevel) {
93        unsafe { msg_send![self.m_self(), setInterruptionLevel: value] }
94    }
95
96    ///The score the system uses to determine if the notification is the summary’s featured notification.
97    #[property]
98    pub fn set_relevance_score(&mut self, value: c_double) {
99        unsafe { msg_send![self.m_self(), setRelevanceScore: value] }
100    }
101
102    /// The criteria the system evaluates to determine if it displays the notification in the current Focus.
103    #[property]
104    pub fn set_filter_criteria(&mut self, value: NSString) {
105        unsafe { msg_send![self.m_self(), setFilterCriteria: value] }
106    }
107
108    /* Grouping notifications
109     */
110
111    /// The identifier that groups related notifications.
112    #[property]
113    pub fn set_thread_identifier(&mut self, value: NSString) {
114        unsafe { msg_send![self.m_self(), setThreadIdentifier: value] }
115    }
116
117    /// The identifier of the notification’s category.
118    #[property]
119    pub fn set_category_identifier(&mut self, value: NSString) {
120        unsafe { msg_send![self.m_self(), setCategoryIdentifier: value] }
121    }
122
123    /// The text the system adds to the notification summary to provide additional context.
124    #[property]
125    pub fn set_summary_argument(&mut self, value: NSString) {
126        unsafe { msg_send![self.m_self(), setSummaryArgument: value] }
127    }
128
129    /// The number the system adds to the notification summary when the notification represents multiple items.
130    #[property]
131    pub fn set_summary_argument_count(&mut self, value: UInt) {
132        unsafe { msg_send![self.m_self(), setSummaryArgumentCount: value] }
133    }
134}