Request

Struct Request 

Source
pub struct Request<T = ()> {
Show 18 fields pub device_token: String, pub push_type: PushType, pub id: Option<Uuid>, pub expiration: Option<OffsetDateTime>, pub priority: Priority, pub topic: Option<String>, pub collapse_id: Option<String>, pub alert: Option<Alert>, pub badge: Option<u32>, pub sound: Option<Sound>, pub thread_id: Option<String>, pub category: Option<String>, pub content_available: bool, pub mutable_content: bool, pub target_content_id: Option<String>, pub interruption_level: Option<InterruptionLevel>, pub relevance_score: Option<f64>, pub user_info: Option<T>,
}
Expand description

Apple Push Notification service request options.

Fields§

§device_token: String

The hex-encoded device token.

§push_type: PushType

(Required for watchOS 6 and later; recommended for macOS, iOS, tvOS, and iPadOS) The value of this header must accurately reflect the contents of your notification’s payload. If there’s a mismatch, or if the header is missing on required systems, APNs may return an error, delay the delivery of the notification, or drop it altogether.

§id: Option<Uuid>

A canonical UUID that is the unique ID for the notification. If an error occurs when sending the notification, APNs includes this value when reporting the error to your server. Canonical UUIDs are 32 lowercase hexadecimal digits, displayed in five groups separated by hyphens in the form 8-4-4-4-12. For example: 123e4567-e89b-12d3-a456-4266554400a0. If you omit this header, APNs creates a UUID for you and returns it in its response.

§expiration: Option<OffsetDateTime>

The date at which the notification is no longer valid. This value is a UNIX epoch expressed in seconds (UTC). If the value is nonzero, APNs stores the notification and tries to deliver it at least once, repeating the attempt as needed until the specified date. If the value is 0, APNs attempts to deliver the notification only once and doesn’t store it.

A single APNs attempt may involve retries over multiple network interfaces and connections of the destination device. Often these retries span over some time period, depending on the network characteristics. In addition, a push notification may take some time on the network after APNs sends it to the device. APNs uses best efforts to honor the expiry date without any guarantee. If the value is nonzero, the notification may be delivered after the mentioned date. If the value is 0, the notification may be delivered with some delay.

§priority: Priority

The priority of the notification. If you omit this header, APNs sets the notification priority to 10.

Specify 10 to send the notification immediately.

Specify 5 to send the notification based on power considerations on the user’s device.

Specify 1 to prioritize the device’s power considerations over all other factors for delivery, and prevent awakening the device.

§topic: Option<String>

The topic for the notification. In general, the topic is your app’s bundle ID/app ID. It can have a suffix based on the type of push notification. If you’re using a certificate that supports PushKit VoIP or watchOS complication notifications, you must include this header with bundle ID of you app and if applicable, the proper suffix. If you’re using token-based authentication with APNs, you must include this header with the correct bundle ID and suffix combination. To learn more about app ID, see Register an App ID.

§collapse_id: Option<String>

An identifier you use to coalesce multiple notifications into a single notification for the user. Typically, each notification request causes a new notification to be displayed on the user’s device. When sending the same notification more than once, use the same value in this header to coalesce the requests. The value of this key must not exceed 64 bytes.

§alert: Option<Alert>

The information for displaying an alert.

§badge: Option<u32>

The number to display in a badge on your app’s icon. Specify 0 to remove the current badge, if any.

§sound: Option<Sound>

The name of a sound file in your app’s main bundle or in the Library/Sounds folder of your app’s container directory or a dictionary that contains sound information for critical alerts.

§thread_id: Option<String>

An app-specific identifier for grouping related notifications. This value corresponds to the threadIdentifier property in the UNNotificationContent object.

§category: Option<String>

The notification’s type. This string must correspond to the identifier of one of the UNNotificationCategory objects you register at launch time. See Declaring Your Actionable Notification Types.

§content_available: bool

The background notification flag. To perform a silent background update, specify the value 1 and don’t include the alert, badge, or sound keys in your payload. See Pushing Background Updates to Your App.

§mutable_content: bool

The notification service app extension flag. If the value is 1, the system passes the notification to your notification service app extension before delivery. Use your extension to modify the notification’s content. See Modifying Content in Newly Delivered Notifications.

§target_content_id: Option<String>

The identifier of the window brought forward. The value of this key will be populated on the UNNotificationContent object created from the push payload. Access the value using the UNNotificationContent object’s targetContentIdentifier property.

§interruption_level: Option<InterruptionLevel>

The importance and delivery timing of a notification. The string values passive, active, time-sensitive, or critical correspond to the UNNotificationInterruptionLevel enumeration cases.

§relevance_score: Option<f64>

The relevance score, a number between 0 and 1, that the system uses to sort the notifications from your app. The highest score gets featured in the notification summary. See relevanceScore.

§user_info: Option<T>

Additional data to send.

Trait Implementations§

Source§

impl<T: Clone> Clone for Request<T>

Source§

fn clone(&self) -> Request<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Request<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Request<T>

Source§

fn default() -> Request<T>

Returns the “default value” for a type. Read more
Source§

impl<T: PartialEq> PartialEq for Request<T>

Source§

fn eq(&self, other: &Request<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> TryFrom<Request<T>> for (HeaderMap<HeaderValue>, Payload<T>)
where T: Serialize,

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(this: Request<T>) -> Result<Self>

Performs the conversion.
Source§

impl<T> StructuralPartialEq for Request<T>

Auto Trait Implementations§

§

impl<T> Freeze for Request<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Request<T>
where T: RefUnwindSafe,

§

impl<T> Send for Request<T>
where T: Send,

§

impl<T> Sync for Request<T>
where T: Sync,

§

impl<T> Unpin for Request<T>
where T: Unpin,

§

impl<T> UnwindSafe for Request<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,