fix(ios): prevent chat crash when Notifications API is unavailable on iPhones

- Guarded all Notification API usage to avoid ReferenceError on iOS Safari.
- Set default permission to 'denied' when Notification is undefined.
- Added early return in notification flow when Notifications API is unavailable.
- Wrapped Notification.permission, requestPermission(), and new Notification(...) with typeof checks.
- Updated SecureNotificationManager and app.jsx to degrade gracefully.
- Verified build passes and chat loads correctly on iOS without notifications.
This commit is contained in:
lockbitchat
2025-10-19 20:51:44 -04:00
parent 4e7f5867b5
commit 906562333e
3 changed files with 10 additions and 8 deletions

6
dist/app.js vendored
View File

@@ -296,8 +296,8 @@ var EnhancedConnectionSetup = ({
if (!window.isSecureContext && window.location.protocol !== "https:" && window.location.hostname !== "localhost") {
return;
}
const currentPermission = Notification.permission;
if (currentPermission === "default") {
const currentPermission = typeof Notification !== "undefined" && Notification ? Notification.permission : "denied";
if (currentPermission === "default" && typeof Notification !== "undefined" && Notification) {
const permission = await Notification.requestPermission();
if (permission === "granted") {
try {
@@ -1678,7 +1678,7 @@ var EnhancedSecureP2PChat = () => {
handleAnswerError,
handleVerificationStateChange
);
if (Notification.permission === "granted" && window.NotificationIntegration && !notificationIntegrationRef.current) {
if (typeof Notification !== "undefined" && Notification && Notification.permission === "granted" && window.NotificationIntegration && !notificationIntegrationRef.current) {
try {
const integration = new window.NotificationIntegration(webrtcManagerRef2.current);
integration.init().then(() => {

4
dist/app.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -320,10 +320,12 @@
}
// Check current permission status
const currentPermission = Notification.permission;
const currentPermission = (typeof Notification !== 'undefined' && Notification)
? Notification.permission
: 'denied';
// Only request if permission is default (not granted or denied)
if (currentPermission === 'default') {
if (currentPermission === 'default' && typeof Notification !== 'undefined' && Notification) {
const permission = await Notification.requestPermission();
if (permission === 'granted') {
@@ -1909,7 +1911,7 @@
);
// Initialize notification integration if permission was already granted
if (Notification.permission === 'granted' && window.NotificationIntegration && !notificationIntegrationRef.current) {
if (typeof Notification !== 'undefined' && Notification && Notification.permission === 'granted' && window.NotificationIntegration && !notificationIntegrationRef.current) {
try {
const integration = new window.NotificationIntegration(webrtcManagerRef.current);
integration.init().then(() => {