2021-04-12 17:20:06 +02:00
|
|
|
//! # Push notifications helper
|
|
|
|
//!
|
|
|
|
//! @author Pierre Hubert
|
|
|
|
|
|
|
|
use crate::data::user_token::{UserAccessToken, PushNotificationToken};
|
|
|
|
use crate::data::error::Res;
|
2021-04-12 17:59:00 +02:00
|
|
|
use crate::helpers::independent_push_notifications_service_helper;
|
2021-04-12 17:20:06 +02:00
|
|
|
|
|
|
|
/// Un-register for previous push notifications service
|
|
|
|
pub fn un_register_from_previous_service(client: &UserAccessToken) -> Res {
|
|
|
|
|
|
|
|
// This method must not fail in case of error
|
|
|
|
if let PushNotificationToken::INDEPENDENT(old_token) = &client.push_notifications_token {
|
2021-04-12 17:59:00 +02:00
|
|
|
if let Err(e) = independent_push_notifications_service_helper::remove_token(old_token) {
|
2021-04-12 17:20:06 +02:00
|
|
|
eprintln!("Failed to un-register from independent push notifications service! {}", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|