diff --git a/desktop/src/push-notifications.js b/desktop/src/push-notifications.js --- a/desktop/src/push-notifications.js +++ b/desktop/src/push-notifications.js @@ -28,9 +28,6 @@ typeof userInfo.body !== 'string' || typeof userInfo.threadID !== 'string' ) { - console.error( - 'Notification must contain a string title, body and threadID', - ); return; } const { title, body, threadID } = userInfo; diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js --- a/keyserver/src/push/send.js +++ b/keyserver/src/push/send.js @@ -186,8 +186,7 @@ const iosVersionsToTokens = byPlatform.get('ios'); if (iosVersionsToTokens) { - for (const [codeVer, deviceTokens] of iosVersionsToTokens) { - const codeVersion = parseInt(codeVer, 10); // only for Flow + for (const [codeVersion, deviceTokens] of iosVersionsToTokens) { const platformDetails = { platform: 'ios', codeVersion }; const shimmedNewRawMessageInfos = shimUnsupportedRawMessageInfos( newRawMessageInfos, @@ -218,8 +217,7 @@ } const androidVersionsToTokens = byPlatform.get('android'); if (androidVersionsToTokens) { - for (const [codeVer, deviceTokens] of androidVersionsToTokens) { - const codeVersion = parseInt(codeVer, 10); // only for Flow + for (const [codeVersion, deviceTokens] of androidVersionsToTokens) { const platformDetails = { platform: 'android', codeVersion }; const shimmedNewRawMessageInfos = shimUnsupportedRawMessageInfos( newRawMessageInfos, @@ -999,8 +997,7 @@ const iosVersionsToTokens = byPlatform.get('ios'); if (iosVersionsToTokens) { - for (const [codeVer, deviceTokens] of iosVersionsToTokens) { - const codeVersion = parseInt(codeVer, 10); // only for Flow + for (const [codeVersion, deviceTokens] of iosVersionsToTokens) { const notification = new apn.Notification(); notification.topic = getAPNsNotificationTopic({ platform: 'ios', @@ -1021,8 +1018,7 @@ const androidVersionsToTokens = byPlatform.get('android'); if (androidVersionsToTokens) { - for (const [codeVer, deviceTokens] of androidVersionsToTokens) { - const codeVersion = parseInt(codeVer, 10); // only for Flow + for (const [codeVersion, deviceTokens] of androidVersionsToTokens) { const notificationData = codeVersion < 69 ? { badge: unreadCount.toString() } @@ -1039,6 +1035,27 @@ } } + const macosVersionsToTokens = byPlatform.get('macos'); + if (macosVersionsToTokens) { + for (const [codeVersion, deviceTokens] of macosVersionsToTokens) { + const notification = new apn.Notification(); + notification.topic = getAPNsNotificationTopic({ + platform: 'macos', + codeVersion, + }); + notification.badge = unreadCount; + notification.pushType = 'alert'; + deliveryPromises.push( + sendAPNsNotification('macos', notification, [...deviceTokens], { + source, + dbID, + userID, + codeVersion, + }), + ); + } + } + const deliveryResults = await Promise.all(deliveryPromises); await saveNotifResults(deliveryResults, new Map(), false); }