rive_http/miscellaneous/
web_push.rs

1use crate::prelude::*;
2use rive_models::data::PushSubscribeData;
3
4impl Client {
5    /// Create a new Web Push subscription.
6    ///
7    /// If an existing subscription exists on this session, it will be removed.
8    pub async fn push_subscribe(&self, data: PushSubscribeData) -> Result<()> {
9        self.client
10            .post(ep!(self, "/push/subscribe"))
11            .json(&data)
12            .auth(&self.authentication)
13            .send()
14            .await?
15            .process_error()
16            .await?;
17        Ok(())
18    }
19
20    /// Remove the Web Push subscription associated with the current session.
21    pub async fn push_unsubscribe(&self) -> Result<()> {
22        self.client
23            .post(ep!(self, "/push/unsubscribe"))
24            .auth(&self.authentication)
25            .send()
26            .await?
27            .process_error()
28            .await?;
29        Ok(())
30    }
31}