Skip to content
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

Support different sounds and priority #18

Closed
jvandenbroek opened this issue Nov 9, 2018 · 20 comments
Closed

Support different sounds and priority #18

jvandenbroek opened this issue Nov 9, 2018 · 20 comments
Labels
a:feature New feature or request

Comments

@jvandenbroek
Copy link

First of all, I'm really thankful someone finally created this self hosted solution :) Works great and seems pretty battery friendly, so I'm really happy with it as alternative for GCM.

Maybe you could extend it functionality a bit with being able to set different sounds per priority? I'd say priority 0 (or -1, don't know what the lowest is actually?) should never play any sound, that one shouldn't be to hard to implement I think? Next step (or maybe the same ;)) would be able to setup different sounds and colors per priority level.

And finally it would be really great if a sound field could be implemented on the server, which the client interprets. Just like pushover allows you to send different sounds, but I could imagine something simpler like settings sound1, sound2, sound3 etc in the client and just use that as value for the sound field.

@jmattheis
Copy link
Member

jmattheis commented Nov 9, 2018

Hey @jvandenbroek

I'm with you there, the priority isn't used anywhere and is currently only saved on server side.
I would map the priority to the Android Importance like this:

Android Importance Gotify Priority
min 0
low 1 - 3
default 4 - 7
high 8 - 10

Each priority 0 - 10 (and 10+) could be a Notification Channel, with Android 8+ a custom sound can be added to each channel.

I don't really use sound on my phone as its mostly on vibrate only, so let's wait for more feedback about the custom sound thingy.
(The importance mapping should still be done in the meantime)

@schwma
Copy link
Contributor

schwma commented Nov 11, 2018

I really like the idea of mapping Gotify message priorities to Android notification channels. So much so that I made a pull request #22 which makes the required changes.

Please let me know if I should make any further changes.

I have a question though @jmattheis. Why did you decide to have such a high granularity of message priorities in Gotify?

@jmattheis
Copy link
Member

@schwma I've added priority really early on, back then all was kinda work in progress, I knew that something like priority should exist but badly I haven't really thought about it, so I just made it integer.

@jvandenbroek
Copy link
Author

@schwma Great work, thanks! However unfortunately I'm only using Android 6, so I think notification channel sound won't work? For now it would be nice if just priority 0 disables sound and vibration, that would be very usable for me.

@schwma
Copy link
Contributor

schwma commented Nov 11, 2018

@jvandenbroek Hmmm, thats strange. The way I understood it, notification channel importances should be backwards compatible. I just tried it on an Android 6 device and all notification channels play sounds and vibrate, so they don't seem to be. I'll try to figure out whats happening when I find the time.

@jvandenbroek
Copy link
Author

jvandenbroek commented Nov 11, 2018

@schwma ah no I misunderstood, because @jmattheis said above for Android 8+, I didn't check this out myself. I (unfortunately) don't have an Android dev environment to build it myself, so haven't tested your PR.. Guess it should work for me as well then, great! 👍

Edit: Ah should read better, he's talking about custom sounds, not channel notification in general, silly me :P

@schwma
Copy link
Contributor

schwma commented Nov 11, 2018

@jvandenbroek Honestly, I'm not sure it will work. I tried it with an Android 6 device that I have here and it didn't work. I'm not entirely sure why though.

@jmattheis
Copy link
Member

@schwma @jvandenbroek NotificationCompact has this method

/**
 * Set the default notification options that will be used.
 * <p>
 * The value should be one or more of the following fields combined with
 * bitwise-or:
 * {@link Notification#DEFAULT_SOUND}, {@link Notification#DEFAULT_VIBRATE},
 * {@link Notification#DEFAULT_LIGHTS}.
 * <p>
 * For all default values, use {@link Notification#DEFAULT_ALL}.
 */
public Builder setDefaults(int defaults) {/*...*/}

Currently DEFAULT_SOUND and DEFAULT_LIGHTS are set on the message notification, (DEFAULT_VIBRATE comes with DEFAULT_SOUND I guess). Without Notification channels there are no restrictions so it just uses these defaults.

@schwma
Copy link
Contributor

schwma commented Nov 11, 2018

@jmattheis But then how do you set no flags at all (or a flag for no sound/vibration/light)? I tried to remove the setDefault() calls entirely, but that didn't seem to change anything.

@jmattheis
Copy link
Member

@schwma Hmm maybe it has some defaults (:, You can try .setDefaults(~Notification.DEFAULT_ALL)

@jmattheis jmattheis added the a:feature New feature or request label Nov 12, 2018
@jmattheis jmattheis mentioned this issue Dec 28, 2018
@nogweii
Copy link

nogweii commented Jan 21, 2019

I would very much like custom sounds myself. It'd be even nicer if I could specify a default sound for an application in the server and have clients automatically download the sound.

@sik0vny
Copy link

sik0vny commented Jan 23, 2019

I was also thinking about defining per-token sound defined in Gotify app. But evaryont has a good point, having a sounds uploaded on server would be great.

The ideal way would be:

  1. Save sounds on server, download them and use them in app (like the icons now)
  2. If user want to override a sound for certain token or all tokens - he can do that by choosing a sound from his SDcard

@jmattheis
Copy link
Member

@evaryont @sik0vny
With Android version 8 you can specify custom sounds. See here how to do it.
It can be configured for each category listed in here.

Tho' it is not customizable for each application and must be customized on each device.

@ktpx
Copy link

ktpx commented Feb 24, 2019

Im currently using pushover, and like their server side sound support. Would be cool to see this on gotify, as in the prosess over moving over.

@jceloria
Copy link

jceloria commented Jun 19, 2020

I recently moved to a pretty rural area where satellite was the only option, I have several notifications that I have come to rely on around my house that I also use pushover for because of the custom sounds. Unfortunately, if its raining then my connection sucks, and I don't get the notifications... This is what ultimately lead me to this project, so a +1 for custom sounds.

@newhinton
Copy link
Contributor

I have tried to implement this feature. But it seems this will not be an easy task, since the setLight() method which is used to set it to Color.CYAN is only obeyed once, and after that it is set as long as its corresponding NotificationChannel exists. I have not tried to find out if this holds true for sounds aswell.

See:
https://stackoverflow.com/questions/53278255/notification-channel-is-it-possible-to-change-lightcolor-after-its-been-set/53288303#53288303
and
https://stackoverflow.com/questions/51032697/allowing-the-user-to-set-notification-light-color-since-oreo-api-26

This means to support this, gotify needs to remove the priority based message channels and create app-based message channels (and recreate them when the user changes light (and possibly sounds)). This comes with its obvious downsides.

@jmattheis Is this something which should be done?

@jmattheis
Copy link
Member

I think removing the channels for priorities will be a no-go. Priorities should still be supported. Maybe we could use the RingtoneManager to play the custom sound: https://stackoverflow.com/a/9622040/4244993

@jmattheis
Copy link
Member

Closing in favor of #75

@jmattheis jmattheis closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2023
@diamondburned
Copy link

Closing in favor of #75

Sorry for commenting on an old issue, but #75 doesn't really discuss the custom sound feature. Could this issue be re-opened for that?

@jmattheis
Copy link
Member

jmattheis commented Mar 30, 2024

You can define a custom notification sound in the android notification settings:

image

Please open a new ticket if you have problems with that, so that not everyone in this thread is notified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature New feature or request
Development

No branches or pull requests

9 participants