objc2_user_notifications/generated/
UNNotificationContent.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_protocol!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unnotificationcontentproviding?language=objc)
12    pub unsafe trait UNNotificationContentProviding: NSObjectProtocol {}
13);
14
15/// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UNNotificationInterruptionLevel(pub NSUInteger);
20impl UNNotificationInterruptionLevel {
21    #[doc(alias = "UNNotificationInterruptionLevelPassive")]
22    pub const Passive: Self = Self(0);
23    #[doc(alias = "UNNotificationInterruptionLevelActive")]
24    pub const Active: Self = Self(1);
25    #[doc(alias = "UNNotificationInterruptionLevelTimeSensitive")]
26    pub const TimeSensitive: Self = Self(2);
27    #[doc(alias = "UNNotificationInterruptionLevelCritical")]
28    pub const Critical: Self = Self(3);
29}
30
31unsafe impl Encode for UNNotificationInterruptionLevel {
32    const ENCODING: Encoding = NSUInteger::ENCODING;
33}
34
35unsafe impl RefEncode for UNNotificationInterruptionLevel {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39extern_class!(
40    /// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unnotificationcontent?language=objc)
41    #[unsafe(super(NSObject))]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    pub struct UNNotificationContent;
44);
45
46unsafe impl NSCoding for UNNotificationContent {}
47
48unsafe impl NSCopying for UNNotificationContent {}
49
50unsafe impl CopyingHelper for UNNotificationContent {
51    type Result = Self;
52}
53
54unsafe impl NSMutableCopying for UNNotificationContent {}
55
56unsafe impl MutableCopyingHelper for UNNotificationContent {
57    type Result = UNMutableNotificationContent;
58}
59
60unsafe impl NSObjectProtocol for UNNotificationContent {}
61
62unsafe impl NSSecureCoding for UNNotificationContent {}
63
64impl UNNotificationContent {
65    extern_methods!(
66        #[cfg(feature = "UNNotificationAttachment")]
67        #[unsafe(method(attachments))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn attachments(&self) -> Retained<NSArray<UNNotificationAttachment>>;
70
71        #[unsafe(method(badge))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn badge(&self) -> Option<Retained<NSNumber>>;
74
75        #[unsafe(method(body))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn body(&self) -> Retained<NSString>;
78
79        #[unsafe(method(categoryIdentifier))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn categoryIdentifier(&self) -> Retained<NSString>;
82
83        #[unsafe(method(launchImageName))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn launchImageName(&self) -> Retained<NSString>;
86
87        #[cfg(feature = "UNNotificationSound")]
88        #[unsafe(method(sound))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn sound(&self) -> Option<Retained<UNNotificationSound>>;
91
92        #[unsafe(method(subtitle))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn subtitle(&self) -> Retained<NSString>;
95
96        #[unsafe(method(threadIdentifier))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn threadIdentifier(&self) -> Retained<NSString>;
99
100        #[unsafe(method(title))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn title(&self) -> Retained<NSString>;
103
104        #[unsafe(method(userInfo))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn userInfo(&self) -> Retained<NSDictionary>;
107
108        /// The argument to be inserted in the summary for this notification.
109        #[deprecated = "summaryArgument is ignored"]
110        #[unsafe(method(summaryArgument))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn summaryArgument(&self) -> Retained<NSString>;
113
114        /// A number that indicates how many items in the summary are represented in the summary.
115        /// For example if a podcast app sends one notification for 3 new episodes in a show,
116        /// the argument should be the name of the show and the count should be 3.
117        /// Default is 1 and cannot be 0.
118        #[deprecated = "summaryArgumentCount is ignored"]
119        #[unsafe(method(summaryArgumentCount))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn summaryArgumentCount(&self) -> NSUInteger;
122
123        #[unsafe(method(targetContentIdentifier))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn targetContentIdentifier(&self) -> Option<Retained<NSString>>;
126
127        #[unsafe(method(interruptionLevel))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn interruptionLevel(&self) -> UNNotificationInterruptionLevel;
130
131        #[unsafe(method(relevanceScore))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn relevanceScore(&self) -> c_double;
134
135        #[unsafe(method(filterCriteria))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn filterCriteria(&self) -> Option<Retained<NSString>>;
138
139        /// Contextualizes your UNNotificationContent object with other Apple SDK objects conforming to UNNotificationContentProviding. This will specialize the notification and decorate its look and behavior accordingly. For example, the notification will be treated as a message with an avatar and be promoted to the top of notification center if the object passed in is a valid INSendMessageIntent
140        /// <UNNotificationContentProviding
141        /// >. This throws an error with a UNErrorCode found in UNError.h if the UNNotificationContentProviding object is invalid. A valid UNNotificationContent result should not be mutated and be passed directly to UNUserNotificationCenter.
142        ///
143        /// This should be called in the UNNotificationServiceExtension in didReceiveNotificationRequest:withContentHandler: and the returned UNNotificationContent should be passed to the contentHandler for incoming push notifications.
144        #[unsafe(method(contentByUpdatingWithProvider:error:_))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn contentByUpdatingWithProvider_error(
147            &self,
148            provider: &ProtocolObject<dyn UNNotificationContentProviding>,
149        ) -> Result<Retained<UNNotificationContent>, Retained<NSError>>;
150    );
151}
152
153/// Methods declared on superclass `NSObject`.
154impl UNNotificationContent {
155    extern_methods!(
156        #[unsafe(method(init))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
159
160        #[unsafe(method(new))]
161        #[unsafe(method_family = new)]
162        pub unsafe fn new() -> Retained<Self>;
163    );
164}
165
166extern_class!(
167    /// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent?language=objc)
168    #[unsafe(super(UNNotificationContent, NSObject))]
169    #[derive(Debug, PartialEq, Eq, Hash)]
170    pub struct UNMutableNotificationContent;
171);
172
173unsafe impl NSCoding for UNMutableNotificationContent {}
174
175unsafe impl NSCopying for UNMutableNotificationContent {}
176
177unsafe impl CopyingHelper for UNMutableNotificationContent {
178    type Result = UNNotificationContent;
179}
180
181unsafe impl NSMutableCopying for UNMutableNotificationContent {}
182
183unsafe impl MutableCopyingHelper for UNMutableNotificationContent {
184    type Result = Self;
185}
186
187unsafe impl NSObjectProtocol for UNMutableNotificationContent {}
188
189unsafe impl NSSecureCoding for UNMutableNotificationContent {}
190
191impl UNMutableNotificationContent {
192    extern_methods!(
193        #[cfg(feature = "UNNotificationAttachment")]
194        #[unsafe(method(attachments))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn attachments(&self) -> Retained<NSArray<UNNotificationAttachment>>;
197
198        #[cfg(feature = "UNNotificationAttachment")]
199        /// Setter for [`attachments`][Self::attachments].
200        #[unsafe(method(setAttachments:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn setAttachments(&self, attachments: &NSArray<UNNotificationAttachment>);
203
204        #[unsafe(method(badge))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn badge(&self) -> Option<Retained<NSNumber>>;
207
208        /// Setter for [`badge`][Self::badge].
209        #[unsafe(method(setBadge:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn setBadge(&self, badge: Option<&NSNumber>);
212
213        #[unsafe(method(body))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn body(&self) -> Retained<NSString>;
216
217        /// Setter for [`body`][Self::body].
218        #[unsafe(method(setBody:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn setBody(&self, body: &NSString);
221
222        #[unsafe(method(categoryIdentifier))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn categoryIdentifier(&self) -> Retained<NSString>;
225
226        /// Setter for [`categoryIdentifier`][Self::categoryIdentifier].
227        #[unsafe(method(setCategoryIdentifier:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn setCategoryIdentifier(&self, category_identifier: &NSString);
230
231        #[unsafe(method(launchImageName))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn launchImageName(&self) -> Retained<NSString>;
234
235        /// Setter for [`launchImageName`][Self::launchImageName].
236        #[unsafe(method(setLaunchImageName:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn setLaunchImageName(&self, launch_image_name: &NSString);
239
240        #[cfg(feature = "UNNotificationSound")]
241        #[unsafe(method(sound))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn sound(&self) -> Option<Retained<UNNotificationSound>>;
244
245        #[cfg(feature = "UNNotificationSound")]
246        /// Setter for [`sound`][Self::sound].
247        #[unsafe(method(setSound:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setSound(&self, sound: Option<&UNNotificationSound>);
250
251        #[unsafe(method(subtitle))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn subtitle(&self) -> Retained<NSString>;
254
255        /// Setter for [`subtitle`][Self::subtitle].
256        #[unsafe(method(setSubtitle:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn setSubtitle(&self, subtitle: &NSString);
259
260        #[unsafe(method(threadIdentifier))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn threadIdentifier(&self) -> Retained<NSString>;
263
264        /// Setter for [`threadIdentifier`][Self::threadIdentifier].
265        #[unsafe(method(setThreadIdentifier:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn setThreadIdentifier(&self, thread_identifier: &NSString);
268
269        #[unsafe(method(title))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn title(&self) -> Retained<NSString>;
272
273        /// Setter for [`title`][Self::title].
274        #[unsafe(method(setTitle:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setTitle(&self, title: &NSString);
277
278        #[unsafe(method(userInfo))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn userInfo(&self) -> Retained<NSDictionary>;
281
282        /// Setter for [`userInfo`][Self::userInfo].
283        #[unsafe(method(setUserInfo:))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn setUserInfo(&self, user_info: &NSDictionary);
286
287        /// The argument to be inserted in the summary for this notification.
288        #[deprecated = "summaryArgument is ignored"]
289        #[unsafe(method(summaryArgument))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn summaryArgument(&self) -> Retained<NSString>;
292
293        /// Setter for [`summaryArgument`][Self::summaryArgument].
294        #[deprecated = "summaryArgument is ignored"]
295        #[unsafe(method(setSummaryArgument:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn setSummaryArgument(&self, summary_argument: &NSString);
298
299        /// A number that indicates how many items in the summary are represented in the summary.
300        /// For example if a podcast app sends one notification for 3 new episodes in a show,
301        /// the argument should be the name of the show and the count should be 3.
302        /// Default is 1 and cannot be 0.
303        #[deprecated = "summaryArgumentCount is ignored"]
304        #[unsafe(method(summaryArgumentCount))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn summaryArgumentCount(&self) -> NSUInteger;
307
308        /// Setter for [`summaryArgumentCount`][Self::summaryArgumentCount].
309        #[deprecated = "summaryArgumentCount is ignored"]
310        #[unsafe(method(setSummaryArgumentCount:))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn setSummaryArgumentCount(&self, summary_argument_count: NSUInteger);
313
314        #[unsafe(method(targetContentIdentifier))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn targetContentIdentifier(&self) -> Option<Retained<NSString>>;
317
318        /// Setter for [`targetContentIdentifier`][Self::targetContentIdentifier].
319        #[unsafe(method(setTargetContentIdentifier:))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn setTargetContentIdentifier(
322            &self,
323            target_content_identifier: Option<&NSString>,
324        );
325
326        #[unsafe(method(interruptionLevel))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn interruptionLevel(&self) -> UNNotificationInterruptionLevel;
329
330        /// Setter for [`interruptionLevel`][Self::interruptionLevel].
331        #[unsafe(method(setInterruptionLevel:))]
332        #[unsafe(method_family = none)]
333        pub unsafe fn setInterruptionLevel(
334            &self,
335            interruption_level: UNNotificationInterruptionLevel,
336        );
337
338        #[unsafe(method(relevanceScore))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn relevanceScore(&self) -> c_double;
341
342        /// Setter for [`relevanceScore`][Self::relevanceScore].
343        #[unsafe(method(setRelevanceScore:))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn setRelevanceScore(&self, relevance_score: c_double);
346
347        #[unsafe(method(filterCriteria))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn filterCriteria(&self) -> Option<Retained<NSString>>;
350
351        /// Setter for [`filterCriteria`][Self::filterCriteria].
352        #[unsafe(method(setFilterCriteria:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn setFilterCriteria(&self, filter_criteria: Option<&NSString>);
355    );
356}
357
358/// Methods declared on superclass `NSObject`.
359impl UNMutableNotificationContent {
360    extern_methods!(
361        #[unsafe(method(init))]
362        #[unsafe(method_family = init)]
363        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
364
365        #[unsafe(method(new))]
366        #[unsafe(method_family = new)]
367        pub unsafe fn new() -> Retained<Self>;
368    );
369}