Skip to content

Commit

Permalink
Upgrade push service with required iOS Topic field
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsosa committed Feb 27, 2018
1 parent f41798d commit 5a20169
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions services/push/routes/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,34 @@ const platform = {

const generatePayload = async function (title, message) {

return {
notifications: [
{
tokens: await getDevicesByPlatform(platform.android),
platform: platform.android,
message: message,
title: title
},
{
tokens: await getDevicesByPlatform(platform.ios),
platform: platform.ios,
message: message,
'alert': {
'title': title,
'body': message,
}
let notifications = [];

let iosTokens = await getDevicesByPlatform(platform.ios),
androidTokens = await getDevicesByPlatform(platform.android);

if (androidTokens.length > 0) {
notifications.push({
tokens: androidTokens,
platform: platform.android,
message: message,
title: title
});
}

if (iosTokens.length > 0) {
notifications.push({
tokens: iosTokens,
platform: platform.ios,
topic: 'com.hackfsu.ios',
message: message,
'alert': {
'title': title,
'body': message,
}
]
};
})
}

return { notifications };
};

module.exports = async function (req, res) {
Expand Down

0 comments on commit 5a20169

Please sign in to comment.