Skip to content

Commit

Permalink
add data parameter to push notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Kalveram committed May 6, 2019
1 parent dcf7ea5 commit 43efaac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions controllers/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const sendPushNotificationsToUsers = (type, latestItem, users) => {
pushNotificationsHelper.sendNotifications(tokens, {
title: notificationTitles[type],
message: type === "events" ? latestItem.title : `${latestItem.title} en ${latestItem.company.name}`,
data: { type, id: latestItem.id },
})
User.setLatestItemIdForUser(tokens, type, latestItem.id).then(res => res)
}
Expand Down
1 change: 1 addition & 0 deletions controllers/reminders.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const sendRemindersForEvent = event => {
pushNotificationsHelper.sendNotifications(tokens, {
title: "Recordatorio para el evento",
message: event.title,
data: { type, id: latestItem.id },
})
})
}
Expand Down
3 changes: 2 additions & 1 deletion services/pushNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const Expo = require("expo-server-sdk")
// Create a new Expo SDK client
const expo = new Expo()

const sendNotifications = (tokens, { title, message }) => {
const sendNotifications = (tokens, { title, message, data }) => {
let messages = []
for (let token of tokens) {
if (!Expo.isExpoPushToken(token)) {
Expand All @@ -15,6 +15,7 @@ const sendNotifications = (tokens, { title, message }) => {
sound: "default",
title: title,
body: message,
data,
})
}

Expand Down

0 comments on commit 43efaac

Please sign in to comment.