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 unsafe fn attachments(&self) -> Retained<NSArray<UNNotificationAttachment>>;
80
81        #[unsafe(method(badge))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn badge(&self) -> Option<Retained<NSNumber>>;
84
85        #[unsafe(method(body))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn body(&self) -> Retained<NSString>;
88
89        #[unsafe(method(categoryIdentifier))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn categoryIdentifier(&self) -> Retained<NSString>;
92
93        #[unsafe(method(launchImageName))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn launchImageName(&self) -> Retained<NSString>;
96
97        #[cfg(feature = "UNNotificationSound")]
98        #[unsafe(method(sound))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn sound(&self) -> Option<Retained<UNNotificationSound>>;
101
102        #[unsafe(method(subtitle))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn subtitle(&self) -> Retained<NSString>;
105
106        #[unsafe(method(threadIdentifier))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn threadIdentifier(&self) -> Retained<NSString>;
109
110        #[unsafe(method(title))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn title(&self) -> Retained<NSString>;
113
114        #[unsafe(method(userInfo))]
115        #[unsafe(method_family = none)]
116        pub unsafe 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 unsafe 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 unsafe fn summaryArgumentCount(&self) -> NSUInteger;
132
133        #[unsafe(method(targetContentIdentifier))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn targetContentIdentifier(&self) -> Option<Retained<NSString>>;
136
137        #[unsafe(method(interruptionLevel))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn interruptionLevel(&self) -> UNNotificationInterruptionLevel;
140
141        #[unsafe(method(relevanceScore))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn relevanceScore(&self) -> c_double;
144
145        #[unsafe(method(filterCriteria))]
146        #[unsafe(method_family = none)]
147        pub unsafe 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 unsafe 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 unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
169
170        #[unsafe(method(new))]
171        #[unsafe(method_family = new)]
172        pub unsafe fn new() -> Retained<Self>;
173    );
174}
175
176extern_class!(
177    /// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent?language=objc)
178    #[unsafe(super(UNNotificationContent, NSObject))]
179    #[derive(Debug, PartialEq, Eq, Hash)]
180    pub struct UNMutableNotificationContent;
181);
182
183extern_conformance!(
184    unsafe impl NSCoding for UNMutableNotificationContent {}
185);
186
187extern_conformance!(
188    unsafe impl NSCopying for UNMutableNotificationContent {}
189);
190
191unsafe impl CopyingHelper for UNMutableNotificationContent {
192    type Result = UNNotificationContent;
193}
194
195extern_conformance!(
196    unsafe impl NSMutableCopying for UNMutableNotificationContent {}
197);
198
199unsafe impl MutableCopyingHelper for UNMutableNotificationContent {
200    type Result = Self;
201}
202
203extern_conformance!(
204    unsafe impl NSObjectProtocol for UNMutableNotificationContent {}
205);
206
207extern_conformance!(
208    unsafe impl NSSecureCoding for UNMutableNotificationContent {}
209);
210
211impl UNMutableNotificationContent {
212    extern_methods!(
213        #[cfg(feature = "UNNotificationAttachment")]
214        #[unsafe(method(attachments))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn attachments(&self) -> Retained<NSArray<UNNotificationAttachment>>;
217
218        #[cfg(feature = "UNNotificationAttachment")]
219        /// Setter for [`attachments`][Self::attachments].
220        #[unsafe(method(setAttachments:))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn setAttachments(&self, attachments: &NSArray<UNNotificationAttachment>);
223
224        #[unsafe(method(badge))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn badge(&self) -> Option<Retained<NSNumber>>;
227
228        /// Setter for [`badge`][Self::badge].
229        #[unsafe(method(setBadge:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn setBadge(&self, badge: Option<&NSNumber>);
232
233        #[unsafe(method(body))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn body(&self) -> Retained<NSString>;
236
237        /// Setter for [`body`][Self::body].
238        #[unsafe(method(setBody:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setBody(&self, body: &NSString);
241
242        #[unsafe(method(categoryIdentifier))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn categoryIdentifier(&self) -> Retained<NSString>;
245
246        /// Setter for [`categoryIdentifier`][Self::categoryIdentifier].
247        #[unsafe(method(setCategoryIdentifier:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setCategoryIdentifier(&self, category_identifier: &NSString);
250
251        #[unsafe(method(launchImageName))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn launchImageName(&self) -> Retained<NSString>;
254
255        /// Setter for [`launchImageName`][Self::launchImageName].
256        #[unsafe(method(setLaunchImageName:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn setLaunchImageName(&self, launch_image_name: &NSString);
259
260        #[cfg(feature = "UNNotificationSound")]
261        #[unsafe(method(sound))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn sound(&self) -> Option<Retained<UNNotificationSound>>;
264
265        #[cfg(feature = "UNNotificationSound")]
266        /// Setter for [`sound`][Self::sound].
267        #[unsafe(method(setSound:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn setSound(&self, sound: Option<&UNNotificationSound>);
270
271        #[unsafe(method(subtitle))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn subtitle(&self) -> Retained<NSString>;
274
275        /// Setter for [`subtitle`][Self::subtitle].
276        #[unsafe(method(setSubtitle:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn setSubtitle(&self, subtitle: &NSString);
279
280        #[unsafe(method(threadIdentifier))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn threadIdentifier(&self) -> Retained<NSString>;
283
284        /// Setter for [`threadIdentifier`][Self::threadIdentifier].
285        #[unsafe(method(setThreadIdentifier:))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn setThreadIdentifier(&self, thread_identifier: &NSString);
288
289        #[unsafe(method(title))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn title(&self) -> Retained<NSString>;
292
293        /// Setter for [`title`][Self::title].
294        #[unsafe(method(setTitle:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn setTitle(&self, title: &NSString);
297
298        #[unsafe(method(userInfo))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn userInfo(&self) -> Retained<NSDictionary>;
301
302        /// Setter for [`userInfo`][Self::userInfo].
303        #[unsafe(method(setUserInfo:))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn setUserInfo(&self, user_info: &NSDictionary);
306
307        /// The argument to be inserted in the summary for this notification.
308        #[deprecated = "summaryArgument is ignored"]
309        #[unsafe(method(summaryArgument))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn summaryArgument(&self) -> Retained<NSString>;
312
313        /// Setter for [`summaryArgument`][Self::summaryArgument].
314        #[deprecated = "summaryArgument is ignored"]
315        #[unsafe(method(setSummaryArgument:))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn setSummaryArgument(&self, summary_argument: &NSString);
318
319        /// A number that indicates how many items in the summary are represented in the summary.
320        /// For example if a podcast app sends one notification for 3 new episodes in a show,
321        /// the argument should be the name of the show and the count should be 3.
322        /// Default is 1 and cannot be 0.
323        #[deprecated = "summaryArgumentCount is ignored"]
324        #[unsafe(method(summaryArgumentCount))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn summaryArgumentCount(&self) -> NSUInteger;
327
328        /// Setter for [`summaryArgumentCount`][Self::summaryArgumentCount].
329        #[deprecated = "summaryArgumentCount is ignored"]
330        #[unsafe(method(setSummaryArgumentCount:))]
331        #[unsafe(method_family = none)]
332        pub unsafe fn setSummaryArgumentCount(&self, summary_argument_count: NSUInteger);
333
334        #[unsafe(method(targetContentIdentifier))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn targetContentIdentifier(&self) -> Option<Retained<NSString>>;
337
338        /// Setter for [`targetContentIdentifier`][Self::targetContentIdentifier].
339        #[unsafe(method(setTargetContentIdentifier:))]
340        #[unsafe(method_family = none)]
341        pub unsafe fn setTargetContentIdentifier(
342            &self,
343            target_content_identifier: Option<&NSString>,
344        );
345
346        #[unsafe(method(interruptionLevel))]
347        #[unsafe(method_family = none)]
348        pub unsafe fn interruptionLevel(&self) -> UNNotificationInterruptionLevel;
349
350        /// Setter for [`interruptionLevel`][Self::interruptionLevel].
351        #[unsafe(method(setInterruptionLevel:))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn setInterruptionLevel(
354            &self,
355            interruption_level: UNNotificationInterruptionLevel,
356        );
357
358        #[unsafe(method(relevanceScore))]
359        #[unsafe(method_family = none)]
360        pub unsafe fn relevanceScore(&self) -> c_double;
361
362        /// Setter for [`relevanceScore`][Self::relevanceScore].
363        #[unsafe(method(setRelevanceScore:))]
364        #[unsafe(method_family = none)]
365        pub unsafe fn setRelevanceScore(&self, relevance_score: c_double);
366
367        #[unsafe(method(filterCriteria))]
368        #[unsafe(method_family = none)]
369        pub unsafe fn filterCriteria(&self) -> Option<Retained<NSString>>;
370
371        /// Setter for [`filterCriteria`][Self::filterCriteria].
372        #[unsafe(method(setFilterCriteria:))]
373        #[unsafe(method_family = none)]
374        pub unsafe fn setFilterCriteria(&self, filter_criteria: Option<&NSString>);
375    );
376}
377
378/// Methods declared on superclass `NSObject`.
379impl UNMutableNotificationContent {
380    extern_methods!(
381        #[unsafe(method(init))]
382        #[unsafe(method_family = init)]
383        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
384
385        #[unsafe(method(new))]
386        #[unsafe(method_family = new)]
387        pub unsafe fn new() -> Retained<Self>;
388    );
389}