rust_macios/user_notifications/
un_location_notification_trigger.rs

1use rust_macios_objective_c_runtime_proc_macros::interface_impl;
2
3use crate::object;
4
5use super::IUNNotificationTrigger;
6
7object! {
8    /// A trigger condition that causes the system to deliver a notification when the user’s device enters or exits a geographic region you specify.
9    unsafe pub struct UNLocationNotificationTrigger;
10}
11
12impl IUNNotificationTrigger for UNLocationNotificationTrigger {}
13
14#[interface_impl(UNNotificationTrigger)]
15impl UNLocationNotificationTrigger {
16    /* Creating a Location Trigger
17     */
18
19    /// Creates a location trigger using the region parameter.
20    ///
21    /// Required features: `"core_location"`
22    #[method]
23    fn trigger_with_region_repeats(region: crate::core_location::CLRegion, repeats: bool) -> Self
24    where
25        Self: Sized + crate::objective_c_runtime::traits::FromId,
26    {
27        use objc::{msg_send, sel, sel_impl};
28
29        unsafe {
30            Self::from_id(msg_send![Self::m_class(), triggerWithRegion: region repeats: repeats])
31        }
32    }
33
34    /// The region used to determine when the system sends the notification.
35    ///
36    /// Required features: `"core_location"`
37    #[property]
38    fn region(&self) -> crate::core_location::CLRegion {
39        use crate::objective_c_runtime::traits::FromId;
40        use objc::{msg_send, sel, sel_impl};
41
42        unsafe { crate::core_location::CLRegion::from_id(msg_send![self.m_self(), region]) }
43    }
44}