objc2_cloud_kit/generated/
CKNotification.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cknotificationid?language=objc)
11    #[unsafe(super(NSObject))]
12    #[derive(Debug, PartialEq, Eq, Hash)]
13    pub struct CKNotificationID;
14);
15
16extern_conformance!(
17    unsafe impl NSCoding for CKNotificationID {}
18);
19
20extern_conformance!(
21    unsafe impl NSCopying for CKNotificationID {}
22);
23
24unsafe impl CopyingHelper for CKNotificationID {
25    type Result = Self;
26}
27
28extern_conformance!(
29    unsafe impl NSObjectProtocol for CKNotificationID {}
30);
31
32extern_conformance!(
33    unsafe impl NSSecureCoding for CKNotificationID {}
34);
35
36impl CKNotificationID {
37    extern_methods!();
38}
39
40/// Methods declared on superclass `NSObject`.
41impl CKNotificationID {
42    extern_methods!(
43        #[unsafe(method(init))]
44        #[unsafe(method_family = init)]
45        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
46
47        #[unsafe(method(new))]
48        #[unsafe(method_family = new)]
49        pub unsafe fn new() -> Retained<Self>;
50    );
51}
52
53/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cknotificationtype?language=objc)
54// NS_ENUM
55#[repr(transparent)]
56#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
57pub struct CKNotificationType(pub NSInteger);
58impl CKNotificationType {
59    /// Generated by `CKQuerySubscription`s
60    #[doc(alias = "CKNotificationTypeQuery")]
61    pub const Query: Self = Self(1);
62    /// Generated by `CKRecordZoneSubscription`s
63    #[doc(alias = "CKNotificationTypeRecordZone")]
64    pub const RecordZone: Self = Self(2);
65    /// Indicates a notification that a client had previously marked as read
66    #[doc(alias = "CKNotificationTypeReadNotification")]
67    pub const ReadNotification: Self = Self(3);
68    /// Generated by `CKDatabaseSubscription`s
69    #[doc(alias = "CKNotificationTypeDatabase")]
70    pub const Database: Self = Self(4);
71}
72
73unsafe impl Encode for CKNotificationType {
74    const ENCODING: Encoding = NSInteger::ENCODING;
75}
76
77unsafe impl RefEncode for CKNotificationType {
78    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
79}
80
81extern_class!(
82    /// Pushes from CloudKit servers contain both CloudKit-specific and APS-specific information.
83    /// APS-specific information includes elements like alerts, badges, sounds, categories, etc.
84    /// When receiving a push from CloudKit servers, the push may be delivered via multiple API flows.
85    /// The flow(s) chosen will depend on the type of push requested (e.g. via the `CKSubscription`
86    /// that triggered it and its configured `notificationInfo`).
87    ///
88    /// Pushes with UI elements (alerts, badges, sounds):
89    /// These pushes are delivered via the `UserNotifications` framework, in the form of a `UNNotification`
90    /// Applications should use the `UserNotifications` framework to interact with the UI elements of this push.
91    /// Applications may create a `CKNotification` from a `UNNotification` in their `UNUserNotificationCenterDelegate`:
92    ///
93    /// func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
94    /// let ckNotification = CKNotification(fromRemoteNotificationDictionary: notification.request.content.userInfo)
95    /// }
96    ///
97    /// Pushes with `content-available`:
98    /// These pushes are delivered via an application delegate, in the form of a remote notification.
99    /// For example: `UIApplicationDelegate.application(_:didReceiveRemoteNotification:) async`
100    /// Applications do not need to interact with any UI element in the push payload argument, that's intended to be handled via the `UserNotifications` flow
101    /// (a push with both UI elements and `content-available` will be delivered via both API flows)
102    /// Applications may create a `CKNotification` from the remote notification in their `UIApplicationDelegate`:
103    ///
104    /// func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) async -> UIBackgroundFetchResult {
105    /// let ckNotification = CKNotification(fromRemoteNotificationDictionary: userInfo)
106    /// }
107    ///
108    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/cknotification?language=objc)
109    #[unsafe(super(NSObject))]
110    #[derive(Debug, PartialEq, Eq, Hash)]
111    pub struct CKNotification;
112);
113
114unsafe impl Send for CKNotification {}
115
116unsafe impl Sync for CKNotification {}
117
118extern_conformance!(
119    unsafe impl NSObjectProtocol for CKNotification {}
120);
121
122impl CKNotification {
123    extern_methods!(
124        #[unsafe(method(init))]
125        #[unsafe(method_family = init)]
126        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
127
128        #[unsafe(method(new))]
129        #[unsafe(method_family = new)]
130        pub unsafe fn new() -> Retained<Self>;
131
132        #[unsafe(method(notificationFromRemoteNotificationDictionary:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn notificationFromRemoteNotificationDictionary(
135            notification_dictionary: &NSDictionary,
136        ) -> Option<Retained<Self>>;
137
138        /// When you instantiate a `CKNotification` from a remote notification dictionary, you will get back a concrete
139        /// subclass defined below.  Use `notificationType` to avoid `as?` or `-isKindOfClass:` checks.
140        #[unsafe(method(notificationType))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn notificationType(&self) -> CKNotificationType;
143
144        #[unsafe(method(notificationID))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn notificationID(&self) -> Option<Retained<CKNotificationID>>;
147
148        #[unsafe(method(containerIdentifier))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn containerIdentifier(&self) -> Option<Retained<NSString>>;
151
152        #[cfg(feature = "CKRecordID")]
153        /// The user `recordID` of the owner of the subscription for which this notification was generated
154        #[unsafe(method(subscriptionOwnerUserRecordID))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn subscriptionOwnerUserRecordID(&self) -> Option<Retained<CKRecordID>>;
157
158        /// Whether or not the notification fully represents what the server wanted to send.
159        ///
160        /// Push notifications have a limited size.  In some cases, CloudKit servers may not be able to send you a full `CKNotification`'s worth of info in one push.
161        /// In those cases, `isPruned` returns `true`.
162        /// The order in which properties are dropped from a push notification is defined in each `CKNotification` subclass below.
163        #[unsafe(method(isPruned))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn isPruned(&self) -> bool;
166
167        #[cfg(feature = "CKSubscription")]
168        /// The ID of the subscription that caused this notification to fire.
169        #[unsafe(method(subscriptionID))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn subscriptionID(&self) -> Option<Retained<CKSubscriptionID>>;
172    );
173}
174
175/// DeprecatedAPSProperties.
176impl CKNotification {
177    extern_methods!(
178        #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
179        #[unsafe(method(alertBody))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn alertBody(&self) -> Option<Retained<NSString>>;
182
183        #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
184        #[unsafe(method(alertLocalizationKey))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn alertLocalizationKey(&self) -> Option<Retained<NSString>>;
187
188        #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
189        #[unsafe(method(alertLocalizationArgs))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn alertLocalizationArgs(&self) -> Option<Retained<NSArray<NSString>>>;
192
193        #[unsafe(method(title))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
196
197        #[unsafe(method(titleLocalizationKey))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn titleLocalizationKey(&self) -> Option<Retained<NSString>>;
200
201        #[unsafe(method(titleLocalizationArgs))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn titleLocalizationArgs(&self) -> Option<Retained<NSArray<NSString>>>;
204
205        #[unsafe(method(subtitle))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;
208
209        #[unsafe(method(subtitleLocalizationKey))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn subtitleLocalizationKey(&self) -> Option<Retained<NSString>>;
212
213        #[unsafe(method(subtitleLocalizationArgs))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn subtitleLocalizationArgs(&self) -> Option<Retained<NSArray<NSString>>>;
216
217        #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
218        #[unsafe(method(alertActionLocalizationKey))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn alertActionLocalizationKey(&self) -> Option<Retained<NSString>>;
221
222        #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
223        #[unsafe(method(alertLaunchImage))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn alertLaunchImage(&self) -> Option<Retained<NSString>>;
226
227        #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
228        #[unsafe(method(badge))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn badge(&self) -> Option<Retained<NSNumber>>;
231
232        #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
233        #[unsafe(method(soundName))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn soundName(&self) -> Option<Retained<NSString>>;
236
237        #[unsafe(method(category))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn category(&self) -> Option<Retained<NSString>>;
240    );
241}
242
243/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckquerynotificationreason?language=objc)
244// NS_ENUM
245#[repr(transparent)]
246#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
247pub struct CKQueryNotificationReason(pub NSInteger);
248impl CKQueryNotificationReason {
249    #[doc(alias = "CKQueryNotificationReasonRecordCreated")]
250    pub const RecordCreated: Self = Self(1);
251    #[doc(alias = "CKQueryNotificationReasonRecordUpdated")]
252    pub const RecordUpdated: Self = Self(2);
253    #[doc(alias = "CKQueryNotificationReasonRecordDeleted")]
254    pub const RecordDeleted: Self = Self(3);
255}
256
257unsafe impl Encode for CKQueryNotificationReason {
258    const ENCODING: Encoding = NSInteger::ENCODING;
259}
260
261unsafe impl RefEncode for CKQueryNotificationReason {
262    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
263}
264
265extern_class!(
266    /// A notification generated by a `CKQuerySubscription`
267    ///
268    /// `notificationType` == `.query`
269    /// When properties must be dropped (see
270    /// `isPruned),`here's the order of importance.  The most important properties are first, they'll be the last ones to be dropped.
271    /// - notificationID
272    /// - badge
273    /// - alertLocalizationKey
274    /// - alertLocalizationArgs
275    /// - alertBody
276    /// - alertActionLocalizationKey
277    /// - alertLaunchImage
278    /// - soundName
279    /// - content-available
280    /// - desiredKeys
281    /// - queryNotificationReason
282    /// - recordID
283    /// - containerIdentifier
284    /// - subscriptionOwnerUserRecordID
285    /// - titleLocalizationKey
286    /// - titleLocalizationArgs
287    /// - title
288    /// - subtitleLocalizationKey
289    /// - subtitleLocalizationArgs
290    /// - subtitle
291    ///
292    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckquerynotification?language=objc)
293    #[unsafe(super(CKNotification, NSObject))]
294    #[derive(Debug, PartialEq, Eq, Hash)]
295    pub struct CKQueryNotification;
296);
297
298unsafe impl Send for CKQueryNotification {}
299
300unsafe impl Sync for CKQueryNotification {}
301
302extern_conformance!(
303    unsafe impl NSObjectProtocol for CKQueryNotification {}
304);
305
306impl CKQueryNotification {
307    extern_methods!(
308        #[unsafe(method(queryNotificationReason))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn queryNotificationReason(&self) -> CKQueryNotificationReason;
311
312        /// A set of key->value pairs for creates and updates.
313        ///
314        /// You request the server fill out this property via the `desiredKeys` property of `CKSubscription.NotificationInfo`
315        #[unsafe(method(recordFields))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn recordFields(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
318
319        #[cfg(feature = "CKRecordID")]
320        #[unsafe(method(recordID))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn recordID(&self) -> Option<Retained<CKRecordID>>;
323
324        #[cfg(feature = "CKDatabase")]
325        #[unsafe(method(databaseScope))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn databaseScope(&self) -> CKDatabaseScope;
328    );
329}
330
331/// Methods declared on superclass `CKNotification`.
332impl CKQueryNotification {
333    extern_methods!(
334        #[unsafe(method(init))]
335        #[unsafe(method_family = init)]
336        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
337
338        #[unsafe(method(new))]
339        #[unsafe(method_family = new)]
340        pub unsafe fn new() -> Retained<Self>;
341
342        #[unsafe(method(notificationFromRemoteNotificationDictionary:))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn notificationFromRemoteNotificationDictionary(
345            notification_dictionary: &NSDictionary,
346        ) -> Option<Retained<Self>>;
347    );
348}
349
350extern_class!(
351    /// A notification generated by a `CKRecordZoneSubscription`
352    ///
353    /// `notificationType` == `.recordZone`
354    /// When properties must be dropped (see
355    /// `isPruned),`here's the order of importance.  The most important properties are first, they'll be the last ones to be dropped.
356    /// - notificationID
357    /// - badge
358    /// - alertLocalizationKey
359    /// - alertLocalizationArgs
360    /// - alertBody
361    /// - alertActionLocalizationKey
362    /// - alertLaunchImage
363    /// - soundName
364    /// - content-available
365    /// - recordZoneID
366    /// - containerIdentifier
367    /// - subscriptionOwnerUserRecordID
368    /// - titleLocalizationKey
369    /// - titleLocalizationArgs
370    /// - title
371    /// - subtitleLocalizationKey
372    /// - subtitleLocalizationArgs
373    /// - subtitle
374    ///
375    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordzonenotification?language=objc)
376    #[unsafe(super(CKNotification, NSObject))]
377    #[derive(Debug, PartialEq, Eq, Hash)]
378    pub struct CKRecordZoneNotification;
379);
380
381unsafe impl Send for CKRecordZoneNotification {}
382
383unsafe impl Sync for CKRecordZoneNotification {}
384
385extern_conformance!(
386    unsafe impl NSObjectProtocol for CKRecordZoneNotification {}
387);
388
389impl CKRecordZoneNotification {
390    extern_methods!(
391        #[cfg(feature = "CKRecordZoneID")]
392        #[unsafe(method(recordZoneID))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn recordZoneID(&self) -> Option<Retained<CKRecordZoneID>>;
395
396        #[cfg(feature = "CKDatabase")]
397        #[unsafe(method(databaseScope))]
398        #[unsafe(method_family = none)]
399        pub unsafe fn databaseScope(&self) -> CKDatabaseScope;
400    );
401}
402
403/// Methods declared on superclass `CKNotification`.
404impl CKRecordZoneNotification {
405    extern_methods!(
406        #[unsafe(method(init))]
407        #[unsafe(method_family = init)]
408        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
409
410        #[unsafe(method(new))]
411        #[unsafe(method_family = new)]
412        pub unsafe fn new() -> Retained<Self>;
413
414        #[unsafe(method(notificationFromRemoteNotificationDictionary:))]
415        #[unsafe(method_family = none)]
416        pub unsafe fn notificationFromRemoteNotificationDictionary(
417            notification_dictionary: &NSDictionary,
418        ) -> Option<Retained<Self>>;
419    );
420}
421
422extern_class!(
423    /// A notification generated by a `CKDatabaseSubscription`
424    ///
425    /// `notificationType` == `.database`
426    /// When properties must be dropped (see
427    /// `isPruned),`here's the order of importance.  The most important properties are first, they'll be the last ones to be dropped.
428    /// - notificationID
429    /// - badge
430    /// - alertLocalizationKey
431    /// - alertLocalizationArgs
432    /// - alertBody
433    /// - alertActionLocalizationKey
434    /// - alertLaunchImage
435    /// - soundName
436    /// - content-available
437    /// - containerIdentifier
438    /// - subscriptionOwnerUserRecordID
439    /// - titleLocalizationKey
440    /// - titleLocalizationArgs
441    /// - title
442    /// - subtitleLocalizationKey
443    /// - subtitleLocalizationArgs
444    /// - subtitle
445    ///
446    /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckdatabasenotification?language=objc)
447    #[unsafe(super(CKNotification, NSObject))]
448    #[derive(Debug, PartialEq, Eq, Hash)]
449    pub struct CKDatabaseNotification;
450);
451
452unsafe impl Send for CKDatabaseNotification {}
453
454unsafe impl Sync for CKDatabaseNotification {}
455
456extern_conformance!(
457    unsafe impl NSObjectProtocol for CKDatabaseNotification {}
458);
459
460impl CKDatabaseNotification {
461    extern_methods!(
462        #[cfg(feature = "CKDatabase")]
463        #[unsafe(method(databaseScope))]
464        #[unsafe(method_family = none)]
465        pub unsafe fn databaseScope(&self) -> CKDatabaseScope;
466    );
467}
468
469/// Methods declared on superclass `CKNotification`.
470impl CKDatabaseNotification {
471    extern_methods!(
472        #[unsafe(method(init))]
473        #[unsafe(method_family = init)]
474        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
475
476        #[unsafe(method(new))]
477        #[unsafe(method_family = new)]
478        pub unsafe fn new() -> Retained<Self>;
479
480        #[unsafe(method(notificationFromRemoteNotificationDictionary:))]
481        #[unsafe(method_family = none)]
482        pub unsafe fn notificationFromRemoteNotificationDictionary(
483            notification_dictionary: &NSDictionary,
484        ) -> Option<Retained<Self>>;
485    );
486}