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