Skip to main content

PushService

Trait PushService 

Source
pub trait PushService {
    // Required methods
    fn available(&self) -> bool;
    fn provider(&self) -> &'static str;
    fn register(&mut self, config: &PushConfig);

    // Provided methods
    fn unregister(&mut self) { ... }
    fn shows_notifications(&self) -> bool { ... }
    fn poll(&mut self) -> Vec<PushEvent> { ... }
}
Expand description

Notificações push (o componente PushNotifications). O registro responde depois: o token, as mensagens e os toques chegam por push_event (de qualquer thread, quando o sistema chama) ou pelo PushService::poll.

Required Methods§

Source

fn available(&self) -> bool

Há um serviço de push aqui (no Android, o Google Play Services; no navegador, a Push API e o service worker).

Source

fn provider(&self) -> &'static str

O serviço: fcm, apns, webpush, wns ou unifiedpush (o servidor precisa saber por onde enviar).

Source

fn register(&mut self, config: &PushConfig)

Pede a permissão de notificar (onde é preciso) e registra; o token chega como PushEvent::Token.

Provided Methods§

Source

fn unregister(&mut self)

Deixa de receber (o token deixa de valer).

Source

fn shows_notifications(&self) -> bool

A própria plataforma mostra a notificação da mensagem (Android, iOS, macOS, navegador). Sem isso (o WNS raw, o UnifiedPush), o componente mostra pelo NotificationService com o show_in_foreground.

Source

fn poll(&mut self) -> Vec<PushEvent>

O que aconteceu desde a última consulta (as plataformas que guardam numa fila).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§