3 var apn = require('apn');
4 var notificationMessageGenerator = require('../notification-message-generator');
6 function generateNewChatNotifications(notificationType, notificationDetails /*, device*/) {
7 var room = notificationDetails.room;
8 var chats = notificationDetails.chats;
9 var hasMentions = notificationDetails.hasMentions;
10 var badgeCount = notificationDetails.badgeCount;
11 var message = notificationMessageGenerator(room, chats);
13 var note = new apn.Notification();
15 if (badgeCount >= 0) {
16 note.badge = badgeCount;
19 note.setAlertText(message);
20 note.sound = hasMentions ? 'notify.caf' : 'notify-2.caf';
21 note.category = 'NEW_CHAT';
24 'content-available': 1,
25 l: '/mobile/chat#' + room.id
32 function generateNotifications(notificationType, notificationDetails, device) {
33 switch (notificationType) {
35 return generateNewChatNotifications(notificationType, notificationDetails, device);
39 module.exports = generateNotifications;