Skip to content

Commit 215bf94

Browse files
committed
fix notification cause crash on android
1 parent 0b99d85 commit 215bf94

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/app/utils/dom.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,15 @@ export const notificationPermission = (permission: NotificationPermission) => {
233233
if ('Notification' in window) {
234234
return window.Notification.permission === permission;
235235
}
236-
return false;
236+
try {
237+
// https://stackoverflow.com/questions/29774836/failed-to-construct-notification-illegal-constructor
238+
// https://issues.chromium.org/issues/40415865
239+
// eslint-disable-next-line no-new
240+
new Notification('');
241+
} catch {
242+
return false;
243+
}
244+
return true;
237245
};
238246

239247
export const getMouseEventCords = (event: MouseEvent) => ({

0 commit comments

Comments
 (0)