fix notification crash on ios (#2192)

* fix notification crash for ios

* access notification from window variable

* fix Notification check

* catch notification variable error

* fix missing check for Notification
This commit is contained in:
Ajay Bura 2025-02-10 21:02:33 +11:00 committed by GitHub
parent 5460e4922b
commit b12228ee95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 31 additions and 14 deletions

View file

@ -8,7 +8,7 @@ import LogoUnreadSVG from '../../../../public/res/svg/cinny-unread.svg';
import LogoHighlightSVG from '../../../../public/res/svg/cinny-highlight.svg';
import NotificationSound from '../../../../public/sound/notification.ogg';
import InviteSound from '../../../../public/sound/invite.ogg';
import { setFavicon } from '../../utils/dom';
import { notificationPermission, setFavicon } from '../../utils/dom';
import { useSetting } from '../../state/hooks/settings';
import { settingsAtom } from '../../state/settings';
import { allInvitesAtom } from '../../state/room-list/inviteList';
@ -110,7 +110,7 @@ function InviteNotifications() {
useEffect(() => {
if (invites.length > perviousInviteLen && mx.getSyncState() === 'SYNCING') {
if (showNotifications && Notification.permission === 'granted') {
if (showNotifications && notificationPermission('granted')) {
notify(invites.length - perviousInviteLen);
}
@ -212,7 +212,7 @@ function MessageNotifications() {
return;
}
if (showNotifications && Notification.permission === 'granted') {
if (showNotifications && notificationPermission('granted')) {
const avatarMxc =
room.getAvatarFallbackMember()?.getMxcAvatarUrl() ?? room.getMxcAvatarUrl();
notify({