Caught errors on webpush

This commit is contained in:
Adolfo Reyna
2025-02-03 22:53:41 -05:00
parent 0ca589cbe8
commit b9a3768f4c

View File

@@ -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