use objc::{msg_send, sel, sel_impl};
use crate::{
foundation::NSString,
object,
objective_c_runtime::{
macros::interface_impl,
traits::{FromId, PNSObject},
},
utils::to_optional,
};
use super::{UNNotificationContent, UNNotificationTrigger};
object! {
unsafe pub struct UNNotificationRequest;
}
#[interface_impl(NSObject)]
impl UNNotificationRequest {
#[method]
pub fn request_with_identifier_content_trigger(
identifier: &NSString,
content: &UNNotificationContent,
trigger: &UNNotificationTrigger,
) -> Self
where
Self: Sized + FromId,
{
unsafe {
Self::from_id(
msg_send![Self::m_class(), requestWithIdentifier: identifier.m_self() content: content.m_self() trigger: trigger.m_self()],
)
}
}
#[property]
pub fn identifier(&self) -> NSString {
unsafe { NSString::from_id(msg_send![self.m_self(), identifier]) }
}
#[property]
pub fn content(&self) -> UNNotificationContent {
unsafe { UNNotificationContent::from_id(msg_send![self.m_self(), content]) }
}
#[property]
pub fn trigger(&self) -> Option<UNNotificationTrigger> {
unsafe { to_optional(msg_send![self.m_self(), trigger]) }
}
}