fix: attempt push notification subscription when permission is default on iOS
This commit is contained in:
@@ -37,17 +37,19 @@ pub fn App() -> impl IntoView {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if Notification API is available and permission is granted
|
// Check if Notification API is available
|
||||||
let window = web_sys::window().expect("window should exist");
|
let window = web_sys::window().expect("window should exist");
|
||||||
if let Ok(notification_class) = js_sys::Reflect::get(&window, &"Notification".into()) {
|
if let Ok(notification_class) = js_sys::Reflect::get(&window, &"Notification".into()) {
|
||||||
if !notification_class.is_undefined() {
|
if !notification_class.is_undefined() {
|
||||||
if let Ok(permission) = js_sys::Reflect::get(¬ification_class, &"permission".into()) {
|
if let Ok(permission) = js_sys::Reflect::get(¬ification_class, &"permission".into()) {
|
||||||
if let Some(perm_str) = permission.as_string() {
|
if let Some(perm_str) = permission.as_string() {
|
||||||
if perm_str == "granted" {
|
// Subscribe if permission is granted or default (not denied)
|
||||||
log::info!("Notification permission granted, subscribing to push...");
|
// The browser will show permission prompt if needed
|
||||||
|
if perm_str != "denied" {
|
||||||
|
log::info!("Subscribing to push notifications (permission: {})", perm_str);
|
||||||
crate::store::subscribe_to_push_notifications().await;
|
crate::store::subscribe_to_push_notifications().await;
|
||||||
} else {
|
} else {
|
||||||
log::info!("Notification permission not granted yet: {}", perm_str);
|
log::info!("Notification permission denied");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user