Allow Web Push setup on Android browsers

This commit is contained in:
zv
2026-06-11 19:54:31 +02:00
parent b945fd4893
commit 47a292b26e
4 changed files with 13 additions and 5 deletions

View File

@@ -21,10 +21,18 @@ function isStandaloneApp() {
return window.matchMedia("(display-mode: standalone)").matches || navigatorWithStandalone.standalone === true;
}
function isAppleMobilePlatform() {
if (typeof window === "undefined") return false;
const userAgent = window.navigator.userAgent;
const platform = window.navigator.platform;
const isIPadOSDesktopMode = platform === "MacIntel" && window.navigator.maxTouchPoints > 1;
return /iPad|iPhone|iPod/.test(userAgent) || isIPadOSDesktopMode;
}
function getNotificationSupportStatus(): NotificationSupportStatus {
if (typeof window === "undefined") return "checking";
if (!("Notification" in window) || !("serviceWorker" in navigator) || !("PushManager" in window)) return "unsupported";
if (!isStandaloneApp()) return "needs-install";
if (isAppleMobilePlatform() && !isStandaloneApp()) return "needs-install";
return Notification.permission;
}