pub struct Notification {Show 13 fields
pub title: String,
pub body: String,
pub category: Option<String>,
pub thread_id: Option<String>,
pub data: Value,
pub collapse_id: Option<String>,
pub priority: Priority,
pub icon: Option<String>,
pub url: Option<String>,
pub ttl: Option<Duration>,
pub badge: Option<u32>,
pub silent: bool,
pub loc: Option<LocKeys>,
}Expand description
One notification, in transport-neutral terms. data is the custom
key-value payload the app reads; collapse_id coalesces notifications the
user has not seen yet.
Every optional field is a request: an adapter maps what its protocol
has and documents what it drops (APNs has no icon, Web Push has no
badge).
Fields§
§title: String§body: String§category: Option<String>The notification category (an app-defined action group).
thread_id: Option<String>Groups related notifications in the UI.
data: ValueCustom payload the app reads; merged alongside the aps block.
collapse_id: Option<String>Coalesces with any undelivered notification carrying the same id.
apns-collapse-id / android.collapse_key / the Web Push Topic
header (≤32 URL-safe characters, so a Web Push adapter shortens it
and documents how).
priority: Priority§icon: Option<String>An icon for the notification (Web Push icon; ignored by APNs, which
takes its icon from the app bundle).
url: Option<String>Where a tap should take the user: the Web Push click target, FCM’s
click_action, and a top-level url in the APNs payload.
ttl: Option<Duration>How long the push service may hold the notification while the device
is offline. Serialised as whole seconds, through ttl_secs.
Note the wire forms differ: apns-expiration is an absolute UNIX
epoch, so the APNs adapter sends now + ttl; android.ttl is
"<s>s"; Web Push TTL is seconds. A zero TTL means “deliver now or
drop” in all three.
Sub-second TTLs round up to one second, on the wire and in every
adapter: Duration::from_millis(900) is a request to hold the
notification briefly, and truncating it to 0 would turn it into
the opposite instruction — drop it the moment the device is offline —
silently, and again on every serde round trip. Only
Duration::ZERO means “drop if undeliverable now”.
badge: Option<u32>The badge number to show on the app icon (iOS). Ignored elsewhere.
silent: boolA data-only notification: nothing is shown, the app is woken to do
work (content-available / FCM data message).
loc: Option<LocKeys>Native localisation keys, in place of title/body, where the
platform supports them.
Implementations§
Trait Implementations§
Source§impl Clone for Notification
impl Clone for Notification
Source§fn clone(&self) -> Notification
fn clone(&self) -> Notification
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Notification
impl Debug for Notification
Source§impl<'de> Deserialize<'de> for Notification
impl<'de> Deserialize<'de> for Notification
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Notification
Source§impl PartialEq for Notification
impl PartialEq for Notification
Source§impl Serialize for Notification
impl Serialize for Notification
impl StructuralPartialEq for Notification
Auto Trait Implementations§
impl Freeze for Notification
impl RefUnwindSafe for Notification
impl Send for Notification
impl Sync for Notification
impl Unpin for Notification
impl UnsafeUnpin for Notification
impl UnwindSafe for Notification
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.