Allow Web Push setup on Android browsers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user