Skip to content

Commit

Permalink
Merge pull request #43 from olusoladavid/ch-refactor-reminder-160126500
Browse files Browse the repository at this point in the history
#160126500 Include message payload in push notifications
  • Loading branch information
olusoladavid committed Aug 29, 2018
2 parents f4b126d + 39c044e commit a306c19
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/workers/sendReminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ const processNotifications = async () => {
users.forEach(async (user) => {
if (user.reminderisset) {
try {
const msg = '{ type: reminder }';
const msg = JSON.stringify({
title: 'What\'s on your mind today?',
body: 'Time to update your diary',
tag: 'reminder',
});
const options = { TTL: 86400 };
const pushSub = JSON.parse(user.push_sub);
await webpush.sendNotification(pushSub, msg, options);
} catch (err) {
console.error(`Could not send reminder for user: ${user.email}`);
console.error(`Could not send reminder for user: ${user.email} due to ${err.message}`);
}
}
});
Expand Down

0 comments on commit a306c19

Please sign in to comment.