From 1c3ee296f7158c8a5eab534913b6bdba0e472c28 Mon Sep 17 00:00:00 2001 From: spinline Date: Fri, 6 Feb 2026 01:06:07 +0300 Subject: [PATCH] fix: skip auto push notification request on Safari (requires user gesture), add debug logs for VAPID key --- frontend/src/app.rs | 16 +++++++++++++++- frontend/src/store.rs | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/frontend/src/app.rs b/frontend/src/app.rs index ca6c952..7d5703a 100644 --- a/frontend/src/app.rs +++ b/frontend/src/app.rs @@ -37,7 +37,21 @@ pub fn App() -> impl IntoView { return; } - // Attempt to subscribe - this will request permission if needed + // Safari requires user gesture for notification permission + // Don't auto-request on Safari - user should click a button + if crate::utils::platform::is_safari() { + log::info!("Safari detected - notification permission requires user interaction. Please click notification settings."); + if let Some(store) = use_context::() { + crate::store::show_toast_with_signal( + store.notifications, + shared::NotificationLevel::Info, + "Bildirim izni için lütfen ayarlara gidin ve izin verin.".to_string(), + ); + } + return; + } + + // For non-Safari browsers (Chrome, Firefox, Edge), attempt auto-subscribe log::info!("Attempting to subscribe to push notifications..."); crate::store::subscribe_to_push_notifications().await; }); diff --git a/frontend/src/store.rs b/frontend/src/store.rs index 0480c6d..bf831a9 100644 --- a/frontend/src/store.rs +++ b/frontend/src/store.rs @@ -362,9 +362,14 @@ pub async fn subscribe_to_push_notifications() { } }; + log::info!("VAPID public key from backend: {} (len: {})", public_key, public_key.len()); + // Convert VAPID public key to Uint8Array let public_key_array = match url_base64_to_uint8array(public_key) { - Ok(arr) => arr, + Ok(arr) => { + log::info!("VAPID key converted to Uint8Array (length: {})", arr.length()); + arr + } Err(e) => { log::error!("Failed to convert VAPID key: {:?}", e); return;