objc2-user-notifications 0.3.2

Bindings to the UserNotifications framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unnotificationcategoryoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UNNotificationCategoryOptions(pub NSUInteger);
bitflags::bitflags! {
    impl UNNotificationCategoryOptions: NSUInteger {
        #[doc(alias = "UNNotificationCategoryOptionCustomDismissAction")]
        const CustomDismissAction = 1<<0;
        #[doc(alias = "UNNotificationCategoryOptionAllowInCarPlay")]
        const AllowInCarPlay = 1<<1;
        #[doc(alias = "UNNotificationCategoryOptionHiddenPreviewsShowTitle")]
        const HiddenPreviewsShowTitle = 1<<2;
        #[doc(alias = "UNNotificationCategoryOptionHiddenPreviewsShowSubtitle")]
        const HiddenPreviewsShowSubtitle = 1<<3;
        #[doc(alias = "UNNotificationCategoryOptionAllowAnnouncement")]
#[deprecated = "Announcement option is ignored"]
        const AllowAnnouncement = 1<<4;
    }
}

unsafe impl Encode for UNNotificationCategoryOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for UNNotificationCategoryOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unnotificationcategoryoptionnone?language=objc)
pub static UNNotificationCategoryOptionNone: UNNotificationCategoryOptions =
    UNNotificationCategoryOptions(0);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/usernotifications/unnotificationcategory?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UNNotificationCategory;
);

extern_conformance!(
    unsafe impl NSCoding for UNNotificationCategory {}
);

extern_conformance!(
    unsafe impl NSCopying for UNNotificationCategory {}
);

unsafe impl CopyingHelper for UNNotificationCategory {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for UNNotificationCategory {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for UNNotificationCategory {}
);

impl UNNotificationCategory {
    extern_methods!(
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub fn identifier(&self) -> Retained<NSString>;

        #[cfg(feature = "UNNotificationAction")]
        #[unsafe(method(actions))]
        #[unsafe(method_family = none)]
        pub fn actions(&self) -> Retained<NSArray<UNNotificationAction>>;

        #[unsafe(method(intentIdentifiers))]
        #[unsafe(method_family = none)]
        pub fn intentIdentifiers(&self) -> Retained<NSArray<NSString>>;

        #[unsafe(method(options))]
        #[unsafe(method_family = none)]
        pub fn options(&self) -> UNNotificationCategoryOptions;

        #[unsafe(method(hiddenPreviewsBodyPlaceholder))]
        #[unsafe(method_family = none)]
        pub fn hiddenPreviewsBodyPlaceholder(&self) -> Retained<NSString>;

        /// A format string for a summary description when notifications from this category are grouped together.
        /// It should contain descriptive text and format arguments that will be replaced with the information
        /// from the notifications that have been grouped together. The arguments are replaced with the number
        /// of notifications and the list created by joining the argument in each grouped notification.
        /// For example: "%u new messages from %@".
        /// The arguments list is optional, "%u new messages" is also accepted.
        #[unsafe(method(categorySummaryFormat))]
        #[unsafe(method_family = none)]
        pub fn categorySummaryFormat(&self) -> Retained<NSString>;

        #[cfg(feature = "UNNotificationAction")]
        #[unsafe(method(categoryWithIdentifier:actions:intentIdentifiers:options:))]
        #[unsafe(method_family = none)]
        pub fn categoryWithIdentifier_actions_intentIdentifiers_options(
            identifier: &NSString,
            actions: &NSArray<UNNotificationAction>,
            intent_identifiers: &NSArray<NSString>,
            options: UNNotificationCategoryOptions,
        ) -> Retained<Self>;

        #[cfg(feature = "UNNotificationAction")]
        #[unsafe(method(categoryWithIdentifier:actions:intentIdentifiers:hiddenPreviewsBodyPlaceholder:options:))]
        #[unsafe(method_family = none)]
        pub fn categoryWithIdentifier_actions_intentIdentifiers_hiddenPreviewsBodyPlaceholder_options(
            identifier: &NSString,
            actions: &NSArray<UNNotificationAction>,
            intent_identifiers: &NSArray<NSString>,
            hidden_previews_body_placeholder: &NSString,
            options: UNNotificationCategoryOptions,
        ) -> Retained<Self>;

        #[cfg(feature = "UNNotificationAction")]
        #[unsafe(method(categoryWithIdentifier:actions:intentIdentifiers:hiddenPreviewsBodyPlaceholder:categorySummaryFormat:options:))]
        #[unsafe(method_family = none)]
        pub fn categoryWithIdentifier_actions_intentIdentifiers_hiddenPreviewsBodyPlaceholder_categorySummaryFormat_options(
            identifier: &NSString,
            actions: &NSArray<UNNotificationAction>,
            intent_identifiers: &NSArray<NSString>,
            hidden_previews_body_placeholder: Option<&NSString>,
            category_summary_format: Option<&NSString>,
            options: UNNotificationCategoryOptions,
        ) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl UNNotificationCategory {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}