fix: skip push notifications on macOS Safari (only iOS supports web push)
This commit is contained in:
@@ -41,19 +41,28 @@ pub fn is_standalone() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if push notifications are supported
|
/// Check if push notifications are supported
|
||||||
|
/// Only iOS Safari supports Web Push Notifications (iOS 16.4+)
|
||||||
|
/// macOS Safari does NOT support Web Push Notifications
|
||||||
pub fn supports_push_notifications() -> bool {
|
pub fn supports_push_notifications() -> bool {
|
||||||
|
// Only iOS supports web push, not macOS Safari
|
||||||
|
if !is_ios() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let window = web_sys::window().expect("window should exist");
|
let window = web_sys::window().expect("window should exist");
|
||||||
|
|
||||||
// Check if PushManager exists
|
// Check if Notification API exists
|
||||||
if let Ok(navigator) = js_sys::Reflect::get(&window, &"navigator".into()) {
|
if let Ok(notification_class) = js_sys::Reflect::get(&window, &"Notification".into()) {
|
||||||
if let Ok(service_worker) = js_sys::Reflect::get(&navigator, &"serviceWorker".into()) {
|
if notification_class.is_undefined() {
|
||||||
if let Ok(push_manager) = js_sys::Reflect::get(&service_worker, &"PushManager".into()) {
|
return false;
|
||||||
return !push_manager.is_undefined();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
false
|
// For iOS, we'll attempt subscription which will check for PushManager
|
||||||
|
// If it's not available, the subscription will fail gracefully
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get platform-specific notification message
|
/// Get platform-specific notification message
|
||||||
|
|||||||
Reference in New Issue
Block a user