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 /// # Safety
133 ///
134 /// `notification_dictionary` generic should be of the correct type.
135 #[unsafe(method(notificationFromRemoteNotificationDictionary:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn notificationFromRemoteNotificationDictionary(
138 notification_dictionary: &NSDictionary,
139 ) -> Option<Retained<Self>>;
140
141 /// When you instantiate a ``CKNotification`` from a remote notification dictionary, you will get back a concrete
142 /// subclass defined below. Use `notificationType` to avoid `as?` or `-isKindOfClass:` checks.
143 ///
144 /// This property is not atomic.
145 ///
146 /// # Safety
147 ///
148 /// This might not be thread-safe.
149 #[unsafe(method(notificationType))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn notificationType(&self) -> CKNotificationType;
152
153 /// This property is not atomic.
154 ///
155 /// # Safety
156 ///
157 /// This might not be thread-safe.
158 #[unsafe(method(notificationID))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn notificationID(&self) -> Option<Retained<CKNotificationID>>;
161
162 /// This property is not atomic.
163 ///
164 /// # Safety
165 ///
166 /// This might not be thread-safe.
167 #[unsafe(method(containerIdentifier))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn containerIdentifier(&self) -> Option<Retained<NSString>>;
170
171 #[cfg(feature = "CKRecordID")]
172 /// The user `recordID` of the owner of the subscription for which this notification was generated
173 ///
174 /// This property is not atomic.
175 ///
176 /// # Safety
177 ///
178 /// This might not be thread-safe.
179 #[unsafe(method(subscriptionOwnerUserRecordID))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn subscriptionOwnerUserRecordID(&self) -> Option<Retained<CKRecordID>>;
182
183 /// Whether or not the notification fully represents what the server wanted to send.
184 ///
185 /// 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.
186 /// In those cases, `isPruned` returns `true`.
187 /// The order in which properties are dropped from a push notification is defined in each ``CKNotification`` subclass below.
188 ///
189 /// This property is not atomic.
190 ///
191 /// # Safety
192 ///
193 /// This might not be thread-safe.
194 #[unsafe(method(isPruned))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn isPruned(&self) -> bool;
197
198 #[cfg(feature = "CKSubscription")]
199 /// The ID of the subscription that caused this notification to fire.
200 ///
201 /// This property is not atomic.
202 ///
203 /// # Safety
204 ///
205 /// This might not be thread-safe.
206 #[unsafe(method(subscriptionID))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn subscriptionID(&self) -> Option<Retained<CKSubscriptionID>>;
209 );
210}
211
212/// DeprecatedAPSProperties.
213#[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
214impl CKNotification {
215 extern_methods!(
216 /// This property is not atomic.
217 ///
218 /// # Safety
219 ///
220 /// This might not be thread-safe.
221 #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
222 #[unsafe(method(alertBody))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn alertBody(&self) -> Option<Retained<NSString>>;
225
226 /// This property is not atomic.
227 ///
228 /// # Safety
229 ///
230 /// This might not be thread-safe.
231 #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
232 #[unsafe(method(alertLocalizationKey))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn alertLocalizationKey(&self) -> Option<Retained<NSString>>;
235
236 /// This property is not atomic.
237 ///
238 /// # Safety
239 ///
240 /// This might not be thread-safe.
241 #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
242 #[unsafe(method(alertLocalizationArgs))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn alertLocalizationArgs(&self) -> Option<Retained<NSArray<NSString>>>;
245
246 /// This property is not atomic.
247 ///
248 /// # Safety
249 ///
250 /// This might not be thread-safe.
251 #[unsafe(method(title))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn title(&self) -> Option<Retained<NSString>>;
254
255 /// This property is not atomic.
256 ///
257 /// # Safety
258 ///
259 /// This might not be thread-safe.
260 #[unsafe(method(titleLocalizationKey))]
261 #[unsafe(method_family = none)]
262 pub unsafe fn titleLocalizationKey(&self) -> Option<Retained<NSString>>;
263
264 /// This property is not atomic.
265 ///
266 /// # Safety
267 ///
268 /// This might not be thread-safe.
269 #[unsafe(method(titleLocalizationArgs))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn titleLocalizationArgs(&self) -> Option<Retained<NSArray<NSString>>>;
272
273 /// This property is not atomic.
274 ///
275 /// # Safety
276 ///
277 /// This might not be thread-safe.
278 #[unsafe(method(subtitle))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;
281
282 /// This property is not atomic.
283 ///
284 /// # Safety
285 ///
286 /// This might not be thread-safe.
287 #[unsafe(method(subtitleLocalizationKey))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn subtitleLocalizationKey(&self) -> Option<Retained<NSString>>;
290
291 /// This property is not atomic.
292 ///
293 /// # Safety
294 ///
295 /// This might not be thread-safe.
296 #[unsafe(method(subtitleLocalizationArgs))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn subtitleLocalizationArgs(&self) -> Option<Retained<NSArray<NSString>>>;
299
300 /// This property is not atomic.
301 ///
302 /// # Safety
303 ///
304 /// This might not be thread-safe.
305 #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
306 #[unsafe(method(alertActionLocalizationKey))]
307 #[unsafe(method_family = none)]
308 pub unsafe fn alertActionLocalizationKey(&self) -> Option<Retained<NSString>>;
309
310 /// This property is not atomic.
311 ///
312 /// # Safety
313 ///
314 /// This might not be thread-safe.
315 #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
316 #[unsafe(method(alertLaunchImage))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn alertLaunchImage(&self) -> Option<Retained<NSString>>;
319
320 /// This property is not atomic.
321 ///
322 /// # Safety
323 ///
324 /// This might not be thread-safe.
325 #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
326 #[unsafe(method(badge))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn badge(&self) -> Option<Retained<NSNumber>>;
329
330 /// This property is not atomic.
331 ///
332 /// # Safety
333 ///
334 /// This might not be thread-safe.
335 #[deprecated = "Interact with UI elements of a CloudKit-server-generated push message via UserNotifications.framework"]
336 #[unsafe(method(soundName))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn soundName(&self) -> Option<Retained<NSString>>;
339
340 /// This property is not atomic.
341 ///
342 /// # Safety
343 ///
344 /// This might not be thread-safe.
345 #[unsafe(method(category))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn category(&self) -> Option<Retained<NSString>>;
348 );
349}
350
351/// [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckquerynotificationreason?language=objc)
352// NS_ENUM
353#[repr(transparent)]
354#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
355pub struct CKQueryNotificationReason(pub NSInteger);
356impl CKQueryNotificationReason {
357 #[doc(alias = "CKQueryNotificationReasonRecordCreated")]
358 pub const RecordCreated: Self = Self(1);
359 #[doc(alias = "CKQueryNotificationReasonRecordUpdated")]
360 pub const RecordUpdated: Self = Self(2);
361 #[doc(alias = "CKQueryNotificationReasonRecordDeleted")]
362 pub const RecordDeleted: Self = Self(3);
363}
364
365unsafe impl Encode for CKQueryNotificationReason {
366 const ENCODING: Encoding = NSInteger::ENCODING;
367}
368
369unsafe impl RefEncode for CKQueryNotificationReason {
370 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
371}
372
373extern_class!(
374 /// A notification generated by a ``CKQuerySubscription``
375 ///
376 /// `notificationType` == `.query`
377 /// When properties must be dropped (see
378 /// `isPruned),`here's the order of importance. The most important properties are first, they'll be the last ones to be dropped.
379 /// - notificationID
380 /// - badge
381 /// - alertLocalizationKey
382 /// - alertLocalizationArgs
383 /// - alertBody
384 /// - alertActionLocalizationKey
385 /// - alertLaunchImage
386 /// - soundName
387 /// - content-available
388 /// - desiredKeys
389 /// - queryNotificationReason
390 /// - recordID
391 /// - containerIdentifier
392 /// - subscriptionOwnerUserRecordID
393 /// - titleLocalizationKey
394 /// - titleLocalizationArgs
395 /// - title
396 /// - subtitleLocalizationKey
397 /// - subtitleLocalizationArgs
398 /// - subtitle
399 ///
400 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckquerynotification?language=objc)
401 #[unsafe(super(CKNotification, NSObject))]
402 #[derive(Debug, PartialEq, Eq, Hash)]
403 pub struct CKQueryNotification;
404);
405
406unsafe impl Send for CKQueryNotification {}
407
408unsafe impl Sync for CKQueryNotification {}
409
410extern_conformance!(
411 unsafe impl NSObjectProtocol for CKQueryNotification {}
412);
413
414impl CKQueryNotification {
415 extern_methods!(
416 /// This property is not atomic.
417 ///
418 /// # Safety
419 ///
420 /// This might not be thread-safe.
421 #[unsafe(method(queryNotificationReason))]
422 #[unsafe(method_family = none)]
423 pub unsafe fn queryNotificationReason(&self) -> CKQueryNotificationReason;
424
425 /// A set of key->value pairs for creates and updates.
426 ///
427 /// You request the server fill out this property via the `desiredKeys` property of `CKSubscription.NotificationInfo`
428 ///
429 /// This property is not atomic.
430 ///
431 /// # Safety
432 ///
433 /// This might not be thread-safe.
434 #[unsafe(method(recordFields))]
435 #[unsafe(method_family = none)]
436 pub unsafe fn recordFields(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
437
438 #[cfg(feature = "CKRecordID")]
439 /// This property is not atomic.
440 ///
441 /// # Safety
442 ///
443 /// This might not be thread-safe.
444 #[unsafe(method(recordID))]
445 #[unsafe(method_family = none)]
446 pub unsafe fn recordID(&self) -> Option<Retained<CKRecordID>>;
447
448 #[cfg(feature = "CKDatabase")]
449 /// This property is not atomic.
450 ///
451 /// # Safety
452 ///
453 /// This might not be thread-safe.
454 #[unsafe(method(databaseScope))]
455 #[unsafe(method_family = none)]
456 pub unsafe fn databaseScope(&self) -> CKDatabaseScope;
457 );
458}
459
460/// Methods declared on superclass `CKNotification`.
461impl CKQueryNotification {
462 extern_methods!(
463 #[unsafe(method(init))]
464 #[unsafe(method_family = init)]
465 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
466
467 #[unsafe(method(new))]
468 #[unsafe(method_family = new)]
469 pub unsafe fn new() -> Retained<Self>;
470
471 /// # Safety
472 ///
473 /// `notification_dictionary` generic should be of the correct type.
474 #[unsafe(method(notificationFromRemoteNotificationDictionary:))]
475 #[unsafe(method_family = none)]
476 pub unsafe fn notificationFromRemoteNotificationDictionary(
477 notification_dictionary: &NSDictionary,
478 ) -> Option<Retained<Self>>;
479 );
480}
481
482extern_class!(
483 /// A notification generated by a ``CKRecordZoneSubscription``
484 ///
485 /// `notificationType` == `.recordZone`
486 /// When properties must be dropped (see
487 /// `isPruned),`here's the order of importance. The most important properties are first, they'll be the last ones to be dropped.
488 /// - notificationID
489 /// - badge
490 /// - alertLocalizationKey
491 /// - alertLocalizationArgs
492 /// - alertBody
493 /// - alertActionLocalizationKey
494 /// - alertLaunchImage
495 /// - soundName
496 /// - content-available
497 /// - recordZoneID
498 /// - containerIdentifier
499 /// - subscriptionOwnerUserRecordID
500 /// - titleLocalizationKey
501 /// - titleLocalizationArgs
502 /// - title
503 /// - subtitleLocalizationKey
504 /// - subtitleLocalizationArgs
505 /// - subtitle
506 ///
507 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckrecordzonenotification?language=objc)
508 #[unsafe(super(CKNotification, NSObject))]
509 #[derive(Debug, PartialEq, Eq, Hash)]
510 pub struct CKRecordZoneNotification;
511);
512
513unsafe impl Send for CKRecordZoneNotification {}
514
515unsafe impl Sync for CKRecordZoneNotification {}
516
517extern_conformance!(
518 unsafe impl NSObjectProtocol for CKRecordZoneNotification {}
519);
520
521impl CKRecordZoneNotification {
522 extern_methods!(
523 #[cfg(feature = "CKRecordZoneID")]
524 /// This property is not atomic.
525 ///
526 /// # Safety
527 ///
528 /// This might not be thread-safe.
529 #[unsafe(method(recordZoneID))]
530 #[unsafe(method_family = none)]
531 pub unsafe fn recordZoneID(&self) -> Option<Retained<CKRecordZoneID>>;
532
533 #[cfg(feature = "CKDatabase")]
534 /// This property is not atomic.
535 ///
536 /// # Safety
537 ///
538 /// This might not be thread-safe.
539 #[unsafe(method(databaseScope))]
540 #[unsafe(method_family = none)]
541 pub unsafe fn databaseScope(&self) -> CKDatabaseScope;
542 );
543}
544
545/// Methods declared on superclass `CKNotification`.
546impl CKRecordZoneNotification {
547 extern_methods!(
548 #[unsafe(method(init))]
549 #[unsafe(method_family = init)]
550 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
551
552 #[unsafe(method(new))]
553 #[unsafe(method_family = new)]
554 pub unsafe fn new() -> Retained<Self>;
555
556 /// # Safety
557 ///
558 /// `notification_dictionary` generic should be of the correct type.
559 #[unsafe(method(notificationFromRemoteNotificationDictionary:))]
560 #[unsafe(method_family = none)]
561 pub unsafe fn notificationFromRemoteNotificationDictionary(
562 notification_dictionary: &NSDictionary,
563 ) -> Option<Retained<Self>>;
564 );
565}
566
567extern_class!(
568 /// A notification generated by a ``CKDatabaseSubscription``
569 ///
570 /// `notificationType` == `.database`
571 /// When properties must be dropped (see
572 /// `isPruned),`here's the order of importance. The most important properties are first, they'll be the last ones to be dropped.
573 /// - notificationID
574 /// - badge
575 /// - alertLocalizationKey
576 /// - alertLocalizationArgs
577 /// - alertBody
578 /// - alertActionLocalizationKey
579 /// - alertLaunchImage
580 /// - soundName
581 /// - content-available
582 /// - containerIdentifier
583 /// - subscriptionOwnerUserRecordID
584 /// - titleLocalizationKey
585 /// - titleLocalizationArgs
586 /// - title
587 /// - subtitleLocalizationKey
588 /// - subtitleLocalizationArgs
589 /// - subtitle
590 ///
591 /// See also [Apple's documentation](https://developer.apple.com/documentation/cloudkit/ckdatabasenotification?language=objc)
592 #[unsafe(super(CKNotification, NSObject))]
593 #[derive(Debug, PartialEq, Eq, Hash)]
594 pub struct CKDatabaseNotification;
595);
596
597unsafe impl Send for CKDatabaseNotification {}
598
599unsafe impl Sync for CKDatabaseNotification {}
600
601extern_conformance!(
602 unsafe impl NSObjectProtocol for CKDatabaseNotification {}
603);
604
605impl CKDatabaseNotification {
606 extern_methods!(
607 #[cfg(feature = "CKDatabase")]
608 /// This property is not atomic.
609 ///
610 /// # Safety
611 ///
612 /// This might not be thread-safe.
613 #[unsafe(method(databaseScope))]
614 #[unsafe(method_family = none)]
615 pub unsafe fn databaseScope(&self) -> CKDatabaseScope;
616 );
617}
618
619/// Methods declared on superclass `CKNotification`.
620impl CKDatabaseNotification {
621 extern_methods!(
622 #[unsafe(method(init))]
623 #[unsafe(method_family = init)]
624 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
625
626 #[unsafe(method(new))]
627 #[unsafe(method_family = new)]
628 pub unsafe fn new() -> Retained<Self>;
629
630 /// # Safety
631 ///
632 /// `notification_dictionary` generic should be of the correct type.
633 #[unsafe(method(notificationFromRemoteNotificationDictionary:))]
634 #[unsafe(method_family = none)]
635 pub unsafe fn notificationFromRemoteNotificationDictionary(
636 notification_dictionary: &NSDictionary,
637 ) -> Option<Retained<Self>>;
638 );
639}