Skip to content

Commit 318ccc0

Browse files
committed
Merge pull request #3 from faizulhaque/master
sound feature for android
2 parents afd267e + 044e10a commit 318ccc0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/android.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function onTransmitted(ctx, intl, notification, recipient) {
7373
});
7474
}
7575

76-
function buildPayload(data) {
76+
function buildPayload(data, is_silent) {
7777
var message = {};
7878
message.priority = data.priority || "high"; //default
7979
message.contentAvailable = data.contentAvailable || true; //default
@@ -89,6 +89,9 @@ function buildPayload(data) {
8989
if(data.icon_file || data.icon) {
9090
message.notification.icon = data.icon_file || data.icon;
9191
}
92+
if(!is_silent) {
93+
message.notification.sound = data.sound || "default";
94+
}
9295
}
9396
message.data = {};
9497
if(data.event_type) {
@@ -129,7 +132,7 @@ function push(ctx, tokens, payload, intl) {
129132
});
130133
}
131134

132-
Android.prototype.send = function send(devices, data) {
135+
Android.prototype.send = function send(devices, data, is_silent) {
133136
var self = this;
134137

135138
var androidDevices = _.filter(devices, function(device) {
@@ -154,7 +157,7 @@ Android.prototype.send = function send(devices, data) {
154157
if(data.not_payload) {
155158
CacheObj.set(options.intl, data.not_payload);
156159
}
157-
var notificationPayload = buildPayload(data);
160+
var notificationPayload = buildPayload(data, is_silent);
158161
push(self, androdTokens, notificationPayload, options.intl);
159162
//global.Trace.write(data.to_id, "push sent to user", notificationPayload, null);
160163
return;

0 commit comments

Comments
 (0)