fix: skip auto push notification request on Safari (requires user gesture), add debug logs for VAPID key
This commit is contained in:
@@ -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::TorrentStore>() {
|
||||
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;
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user