diff --git a/notifications.js b/notifications.js index c9e131b..e832156 100644 --- a/notifications.js +++ b/notifications.js @@ -4,11 +4,16 @@ const { Expo } = require('expo-server-sdk'); const webPush = require('web-push'); const sendWebNotification = async (subscription, title, body) => { - const payload = JSON.stringify({ - title, - body - }); - webPush.sendNotification(subscription, payload); + try { + const payload = JSON.stringify({ + title, + body + }); + webPush.sendNotification(subscription, payload); + } catch (error) { + console.error('Error sending web notification', error); + } + } // Expo API to send push notifications, this code was a provided snipped