phonegap-build / PushPlugin

This repository is deprecated head to phonegap/phonegap-push-plugin
https://github.com/phonegap/phonegap-plugin-push
MIT License
1.31k stars 996 forks source link

Turn off notification sound on Android #159

Open rvanoord opened 10 years ago

rvanoord commented 10 years ago

Hi,

Several users of apps using the PushPlugin have requested the option to turn off notification sound (without necessarily turning off all sounds on the device)

Is there a way of determining whether or not Android devices play a sound when a push notification comes in and the app is in the background or not started?

RVO

ghost commented 10 years ago

I'm also interested in this issue in my app I want that acording the "hour of the day" the sound and vibration will apears with the notification or not.

wroscoe commented 10 years ago

Yep, I'd also like to know how to do this. I'd like to let the users to set what type (sound, vibration ,... ) of notification they get when they get a GCM push notification.

andreszs commented 9 years ago

No news on this setting yet? I guess this is determined by GCM, is that correct?

bostondv commented 9 years ago

Seems you can control sound, vibrate and lights by passing a value into a defaults parameter in the payload.

The defaults can be set to one of the constants here: http://developer.android.com/reference/android/app/Notification.html#DEFAULT_ALL

It only works with the constant value eg. 1 and not a constant name eg. DEFAULT_SOUND.

var payload = { defaults: 1 }

rupertbear commented 9 years ago

Thanks for the tip bostondv! Just tried it out and if you go with the 4 for the lights option that's as good as a mute on my Nexus 5. Just add it to the data portion

'{"data":{"title":"Shhhh!","message":"Keep it down","defaults":4}}