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
46extern_conformance!(
47    unsafe impl NSCoding for UNNotificationContent {}
48);
49
50extern_conformance!(
51    unsafe impl NSCopying for UNNotificationContent {}
52);
53
54unsafe impl CopyingHelper for UNNotificationContent {
55    type Result = Self;
56}
57
58extern_conformance!(
59    unsafe impl NSMutableCopying for UNNotificationContent {}
60);
61
62unsafe impl MutableCopyingHelper for UNNotificationContent {
63    type Result = UNMutableNotificationContent;
64}
65
66extern_conformance!(
67    unsafe impl NSObjectProtocol for UNNotificationContent {}
68);
69
70extern_conformance!(
71    unsafe impl NSSecureCoding for UNNotificationContent {}
72);
73
74impl UNNotificationContent {
75    extern_methods!(
76        #[cfg(feature = "UNNotificationAttachment")]
77        #[unsafe(method(attachments))]
78        #[unsafe(method_family = none)]
79        pub fn attachments(&self) -> Retained<NSArray<UNNotificationAttachment>>;
80
81        #[unsafe(method(badge))]
82        #[unsafe(method_family = none)]
83        pub fn badge(&self) -> Option<Retained<NSNumber>>;
84
85        #[unsafe(method(body))]
86        #[unsafe(method_family = none)]
87        pub fn body(&self) -> Retained<NSString>;
88
89        #[unsafe(method(categoryIdentifier))]
90        #[unsafe(method_family = none)]
91        pub fn categoryIdentifier(&self) -> Retained<NSString>;
92
93        #[unsafe(method(launchImageName))]
94        #[unsafe(method_family = none)]
95        pub fn launchImageName(&self) -> Retained<NSString>;
96
97        #[cfg(feature = "UNNotificationSound")]
98        #[unsafe(method(sound))]
99        #[unsafe(method_family = none)]
100        pub fn sound(&self) -> Option<Retained<UNNotificationSound>>;
101
102        #[unsafe(method(subtitle))]
103        #[unsafe(method_family = none)]
104        pub fn subtitle(&self) -> Retained<NSString>;
105
106        #[unsafe(method(threadIdentifier))]
107        #[unsafe(method_family = none)]
108        pub fn threadIdentifier(&self) -> Retained<NSString>;
109
110        #[unsafe(method(title))]
111        #[unsafe(method_family = none)]
112        pub fn title(&self) -> Retained<NSString>;
113
114        #[unsafe(method(userInfo))]
115        #[unsafe(method_family = none)]
116        pub fn userInfo(&self) -> Retained<NSDictionary>;
117
118        /// The argument to be inserted in the summary for this notification.
119        #[deprecated = "summaryArgument is ignored"]
120        #[unsafe(method(summaryArgument))]
121        #[unsafe(method_family = none)]
122        pub fn summaryArgument(&self) -> Retained<NSString>;
123
124        /// A number that indicates how many items in the summary are represented in the summary.
125        /// For example if a podcast app sends one notification for 3 new episodes in a show,
126        /// the argument should be the name of the show and the count should be 3.
127        /// Default is 1 and cannot be 0.
128        #[deprecated = "summaryArgumentCount is ignored"]
129        #[unsafe(method(summaryArgumentCount))]
130        #[unsafe(method_family = none)]
131        pub fn summaryArgumentCount(&self) -> NSUInteger;
132
133        #[unsafe(method(targetContentIdentifier))]
134        #[unsafe(method_family = none)]
135        pub fn targetContentIdentifier(&self) -> Option<Retained<NSString>>;
136
137        #[unsafe(method(interruptionLevel))]
138        #[unsafe(method_family = none)]
139        pub fn interruptionLevel(&self) -> UNNotificationInterruptionLevel;
140
141        #[unsafe(method(relevanceScore))]
142        #[unsafe(method_family = none)]
143        pub fn relevanceScore(&self) -> c_double;
144
145        #[unsafe(method(filterCriteria))]
146        #[unsafe(method_family = none)]
147        pub fn filterCriteria(&self) -> Option<Retained<NSString>>;
148
149        /// 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
150        /// <UNNotificationContentProviding
151        /// >. 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.
152        ///
153        /// This should be called in the UNNotificationServiceExtension in didReceiveNotificationRequest:withContentHandler: and the returned UNNotificationContent should be passed to the contentHandler for incoming push notifications.
154        #[unsafe(method(contentByUpdatingWithProvider:error:_))]
155        #[unsafe(method_family = none)]
156        pub fn contentByUpdatingWithProvider_error(
157            &self,
158            provider: &ProtocolObject<dyn UNNotificationContentProviding>,
159        ) -> Result<Retained<UNNotificationContent>, Retained<NSError>>;
160    );
161}
162
163/// Methods declared on superclass `NSObject`.
164impl UNNotificationContent {
165    extern_methods!(
166        #[unsafe(method(init))]
167        #[unsafe(method_family = init)]
168        pub fn init(this: Allocated<Self>) -> Retained<Self>;
169
170        #[unsafe(method(new))]
171        #[unsafe(method_family = new)]
172        pub fn new() -> Retained<Self>;
173    );
174}
175
176impl DefaultRetained for UNNotificationContent {
177    #[inline]
178    fn default_retained() -> Retained<Self> {
179        Self::new()
180    }
181}
182
183extern_class!(
184    /// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent?language=objc)
185    #[unsafe(super(UNNotificationContent, NSObject))]
186    #[derive(Debug, PartialEq, Eq, Hash)]
187    pub struct UNMutableNotificationContent;
188);
189
190extern_conformance!(
191    unsafe impl NSCoding for UNMutableNotificationContent {}
192);
193
194extern_conformance!(
195    unsafe impl NSCopying for UNMutableNotificationContent {}
196);
197
198unsafe impl CopyingHelper for UNMutableNotificationContent {
199    type Result = UNNotificationContent;
200}
201
202extern_conformance!(
203    unsafe impl NSMutableCopying for UNMutableNotificationContent {}
204);
205
206unsafe impl MutableCopyingHelper for UNMutableNotificationContent {
207    type Result = Self;
208}
209
210extern_conformance!(
211    unsafe impl NSObjectProtocol for UNMutableNotificationContent {}
212);
213
214extern_conformance!(
215    unsafe impl NSSecureCoding for UNMutableNotificationContent {}
216);
217
218impl UNMutableNotificationContent {
219    extern_methods!(
220        #[cfg(feature = "UNNotificationAttachment")]
221        #[unsafe(method(attachments))]
222        #[unsafe(method_family = none)]
223        pub fn attachments(&self) -> Retained<NSArray<UNNotificationAttachment>>;
224
225        #[cfg(feature = "UNNotificationAttachment")]
226        /// Setter for [`attachments`][Self::attachments].
227        ///
228        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
229        #[unsafe(method(setAttachments:))]
230        #[unsafe(method_family = none)]
231        pub fn setAttachments(&self, attachments: &NSArray<UNNotificationAttachment>);
232
233        #[unsafe(method(badge))]
234        #[unsafe(method_family = none)]
235        pub fn badge(&self) -> Option<Retained<NSNumber>>;
236
237        /// Setter for [`badge`][Self::badge].
238        ///
239        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
240        #[unsafe(method(setBadge:))]
241        #[unsafe(method_family = none)]
242        pub fn setBadge(&self, badge: Option<&NSNumber>);
243
244        #[unsafe(method(body))]
245        #[unsafe(method_family = none)]
246        pub fn body(&self) -> Retained<NSString>;
247
248        /// Setter for [`body`][Self::body].
249        ///
250        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
251        #[unsafe(method(setBody:))]
252        #[unsafe(method_family = none)]
253        pub fn setBody(&self, body: &NSString);
254
255        #[unsafe(method(categoryIdentifier))]
256        #[unsafe(method_family = none)]
257        pub fn categoryIdentifier(&self) -> Retained<NSString>;
258
259        /// Setter for [`categoryIdentifier`][Self::categoryIdentifier].
260        ///
261        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
262        #[unsafe(method(setCategoryIdentifier:))]
263        #[unsafe(method_family = none)]
264        pub fn setCategoryIdentifier(&self, category_identifier: &NSString);
265
266        #[unsafe(method(launchImageName))]
267        #[unsafe(method_family = none)]
268        pub fn launchImageName(&self) -> Retained<NSString>;
269
270        /// Setter for [`launchImageName`][Self::launchImageName].
271        ///
272        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
273        #[unsafe(method(setLaunchImageName:))]
274        #[unsafe(method_family = none)]
275        pub fn setLaunchImageName(&self, launch_image_name: &NSString);
276
277        #[cfg(feature = "UNNotificationSound")]
278        #[unsafe(method(sound))]
279        #[unsafe(method_family = none)]
280        pub fn sound(&self) -> Option<Retained<UNNotificationSound>>;
281
282        #[cfg(feature = "UNNotificationSound")]
283        /// Setter for [`sound`][Self::sound].
284        ///
285        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
286        #[unsafe(method(setSound:))]
287        #[unsafe(method_family = none)]
288        pub fn setSound(&self, sound: Option<&UNNotificationSound>);
289
290        #[unsafe(method(subtitle))]
291        #[unsafe(method_family = none)]
292        pub fn subtitle(&self) -> Retained<NSString>;
293
294        /// Setter for [`subtitle`][Self::subtitle].
295        ///
296        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
297        #[unsafe(method(setSubtitle:))]
298        #[unsafe(method_family = none)]
299        pub fn setSubtitle(&self, subtitle: &NSString);
300
301        #[unsafe(method(threadIdentifier))]
302        #[unsafe(method_family = none)]
303        pub fn threadIdentifier(&self) -> Retained<NSString>;
304
305        /// Setter for [`threadIdentifier`][Self::threadIdentifier].
306        ///
307        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
308        #[unsafe(method(setThreadIdentifier:))]
309        #[unsafe(method_family = none)]
310        pub fn setThreadIdentifier(&self, thread_identifier: &NSString);
311
312        #[unsafe(method(title))]
313        #[unsafe(method_family = none)]
314        pub fn title(&self) -> Retained<NSString>;
315
316        /// Setter for [`title`][Self::title].
317        ///
318        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
319        #[unsafe(method(setTitle:))]
320        #[unsafe(method_family = none)]
321        pub fn setTitle(&self, title: &NSString);
322
323        #[unsafe(method(userInfo))]
324        #[unsafe(method_family = none)]
325        pub fn userInfo(&self) -> Retained<NSDictionary>;
326
327        /// Setter for [`userInfo`][Self::userInfo].
328        ///
329        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
330        ///
331        /// # Safety
332        ///
333        /// `user_info` generic should be of the correct type.
334        #[unsafe(method(setUserInfo:))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn setUserInfo(&self, user_info: &NSDictionary);
337
338        /// The argument to be inserted in the summary for this notification.
339        #[deprecated = "summaryArgument is ignored"]
340        #[unsafe(method(summaryArgument))]
341        #[unsafe(method_family = none)]
342        pub fn summaryArgument(&self) -> Retained<NSString>;
343
344        /// Setter for [`summaryArgument`][Self::summaryArgument].
345        ///
346        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
347        #[deprecated = "summaryArgument is ignored"]
348        #[unsafe(method(setSummaryArgument:))]
349        #[unsafe(method_family = none)]
350        pub fn setSummaryArgument(&self, summary_argument: &NSString);
351
352        /// A number that indicates how many items in the summary are represented in the summary.
353        /// For example if a podcast app sends one notification for 3 new episodes in a show,
354        /// the argument should be the name of the show and the count should be 3.
355        /// Default is 1 and cannot be 0.
356        #[deprecated = "summaryArgumentCount is ignored"]
357        #[unsafe(method(summaryArgumentCount))]
358        #[unsafe(method_family = none)]
359        pub fn summaryArgumentCount(&self) -> NSUInteger;
360
361        /// Setter for [`summaryArgumentCount`][Self::summaryArgumentCount].
362        #[deprecated = "summaryArgumentCount is ignored"]
363        #[unsafe(method(setSummaryArgumentCount:))]
364        #[unsafe(method_family = none)]
365        pub fn setSummaryArgumentCount(&self, summary_argument_count: NSUInteger);
366
367        #[unsafe(method(targetContentIdentifier))]
368        #[unsafe(method_family = none)]
369        pub fn targetContentIdentifier(&self) -> Option<Retained<NSString>>;
370
371        /// Setter for [`targetContentIdentifier`][Self::targetContentIdentifier].
372        ///
373        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
374        #[unsafe(method(setTargetContentIdentifier:))]
375        #[unsafe(method_family = none)]
376        pub fn setTargetContentIdentifier(&self, target_content_identifier: Option<&NSString>);
377
378        #[unsafe(method(interruptionLevel))]
379        #[unsafe(method_family = none)]
380        pub fn interruptionLevel(&self) -> UNNotificationInterruptionLevel;
381
382        /// Setter for [`interruptionLevel`][Self::interruptionLevel].
383        #[unsafe(method(setInterruptionLevel:))]
384        #[unsafe(method_family = none)]
385        pub fn setInterruptionLevel(&self, interruption_level: UNNotificationInterruptionLevel);
386
387        #[unsafe(method(relevanceScore))]
388        #[unsafe(method_family = none)]
389        pub fn relevanceScore(&self) -> c_double;
390
391        /// Setter for [`relevanceScore`][Self::relevanceScore].
392        #[unsafe(method(setRelevanceScore:))]
393        #[unsafe(method_family = none)]
394        pub fn setRelevanceScore(&self, relevance_score: c_double);
395
396        #[unsafe(method(filterCriteria))]
397        #[unsafe(method_family = none)]
398        pub fn filterCriteria(&self) -> Option<Retained<NSString>>;
399
400        /// Setter for [`filterCriteria`][Self::filterCriteria].
401        ///
402        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
403        #[unsafe(method(setFilterCriteria:))]
404        #[unsafe(method_family = none)]
405        pub fn setFilterCriteria(&self, filter_criteria: Option<&NSString>);
406    );
407}
408
409/// Methods declared on superclass `NSObject`.
410impl UNMutableNotificationContent {
411    extern_methods!(
412        #[unsafe(method(init))]
413        #[unsafe(method_family = init)]
414        pub fn init(this: Allocated<Self>) -> Retained<Self>;
415
416        #[unsafe(method(new))]
417        #[unsafe(method_family = new)]
418        pub fn new() -> Retained<Self>;
419    );
420}
421
422impl DefaultRetained for UNMutableNotificationContent {
423    #[inline]
424    fn default_retained() -> Retained<Self> {
425        Self::new()
426    }
427}