From 7a5dca2645b8988e4d76028b0673a991b74b6dad Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 1 Jul 2024 14:13:54 +0000 Subject: [PATCH] fix: do not try to register non-iOS tokens for heartbeats Notification server uses APNS server for heartbeat notifications, so registering FCM tokens there will result in failing to notify them and unregistering them anyway. --- src/push.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/push.rs b/src/push.rs index 9196ab855..def916611 100644 --- a/src/push.rs +++ b/src/push.rs @@ -5,7 +5,6 @@ use anyhow::Result; use tokio::sync::RwLock; use crate::context::Context; -use crate::net::http; /// Manages subscription to Apple Push Notification services. /// @@ -48,7 +47,10 @@ impl PushSubscriber { } /// Subscribes for heartbeat notifications with previously set device token. + #[cfg(target_os = "ios")] pub(crate) async fn subscribe(&self) -> Result<()> { + use crate::net::http; + let mut state = self.inner.write().await; if state.heartbeat_subscribed { @@ -73,6 +75,14 @@ impl PushSubscriber { Ok(()) } + /// Placeholder to skip subscribing to heartbeat notifications outside iOS. + #[cfg(not(target_os = "ios"))] + pub(crate) async fn subscribe(&self) -> Result<()> { + let mut state = self.inner.write().await; + state.heartbeat_subscribed = true; + Ok(()) + } + pub(crate) async fn heartbeat_subscribed(&self) -> bool { self.inner.read().await.heartbeat_subscribed }