Skip to main content

Bark

Struct Bark 

Source
pub struct Bark { /* private fields */ }
Expand description

Direct APNs client for Bark notifications.

Bark signs APNs provider tokens with Bark’s default credentials by default and sends serialized Message payloads to iOS device tokens. It talks to APNs directly; no Bark server is contacted.

Device tokens are normalized before sending: surrounding angle brackets and ASCII whitespace are removed, and duplicate tokens are sent once.

Implementations§

Source§

impl Bark

Source

pub fn new() -> Result<Self>

Creates a client using Bark’s default APNs team id, key id, topic, and private key.

This matches the public Bark app topic me.fin.bark.

§Errors

Returns an error if the built-in APNs key cannot be parsed or the HTTP clients cannot be constructed.

Source

pub fn with_credentials<T, K, O, P>( team_id: T, auth_key_id: K, topic: O, private_key_pem: P, ) -> Result<Self>
where T: Into<String>, K: Into<String>, O: Into<String>, P: Into<String>,

Creates a client with custom APNs credentials.

Use this for a forked Bark app or a private APNs topic. The private key must be an APNs Auth Key in PEM format for ES256 signing.

§Errors

Returns an error if the private key cannot be parsed or the HTTP clients cannot be constructed.

Source

pub fn production(self) -> Self

Selects APNs production.

This is the default and sends to api.push.apple.com.

Source

pub fn sandbox(self) -> Self

Selects APNs sandbox.

This sends to api.sandbox.push.apple.com, useful for development builds whose device tokens belong to the sandbox environment.

Source

pub fn team_id(&self) -> &str

Returns the APNs team id used for provider-token signing.

Source

pub fn auth_key_id(&self) -> &str

Returns the APNs auth key id used in the JWT header.

Source

pub fn topic(&self) -> &str

Returns the APNs topic, normally Bark’s bundle id.

Source

pub fn send<I, D>(&self, message: &Message, devices: I) -> Result<()>
where I: IntoIterator<Item = D>, D: Into<String>,

Sends a message synchronously to one or more device tokens.

The same serialized APNs payload is sent to each unique normalized token. For delete messages this method uses APNs background push type and priority 5; otherwise it uses alert push type and priority 10.

§Errors

Returns Error::ApnsFailures if any device fails. The error message includes the normalized device token and reason for each failed device. Validation, serialization, encryption, token-signing, and HTTP client errors are returned directly.

Source

pub async fn send_async<I, D>( &self, message: &Message, devices: I, ) -> Result<()>
where I: IntoIterator<Item = D>, D: Into<String>,

Sends a message asynchronously to one or more device tokens.

This has the same payload and error semantics as Bark::send, but uses the asynchronous reqwest client.

§Errors

Returns Error::ApnsFailures if any device fails. The error message includes the normalized device token and reason for each failed device. Validation, serialization, encryption, token-signing, and HTTP client errors are returned directly.

Auto Trait Implementations§

§

impl !Freeze for Bark

§

impl !RefUnwindSafe for Bark

§

impl !UnwindSafe for Bark

§

impl Send for Bark

§

impl Sync for Bark

§

impl Unpin for Bark

§

impl UnsafeUnpin for Bark

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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