Skip to content

sound feature for android #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function onTransmitted(ctx, intl, notification, recipient) {
});
}

function buildPayload(data) {
function buildPayload(data, is_silent) {
var message = {};
message.priority = data.priority || "high"; //default
message.contentAvailable = data.contentAvailable || true; //default
Expand All @@ -89,6 +89,9 @@ function buildPayload(data) {
if(data.icon_file || data.icon) {
message.notification.icon = data.icon_file || data.icon;
}
if(!is_silent) {
message.notification.sound = data.sound || "default";
}
}
message.data = {};
if(data.event_type) {
Expand Down Expand Up @@ -129,7 +132,7 @@ function push(ctx, tokens, payload, intl) {
});
}

Android.prototype.send = function send(devices, data) {
Android.prototype.send = function send(devices, data, is_silent) {
var self = this;

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