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

Emergency Priority on Android #417

Closed
danmed opened this issue Sep 29, 2022 · 26 comments
Closed

Emergency Priority on Android #417

danmed opened this issue Sep 29, 2022 · 26 comments
Labels
android-app ntfy Android app enhancement New feature or request in-progress 🏃 I'm working on this right now

Comments

@danmed
Copy link

danmed commented Sep 29, 2022

I've been trying out ntfy and it's.. well it's awesome.. so much quicker than pushover..

The problem i have is that i want to use it for my alarm notifications but i cannot figure out how to set it as an emergency alert on android.

My phone is almost always on vibrate only and after 11pm it's in DND.

I've figured out how to ignore DND.. but how can i get it to ignore vibrate and play a sound (loud!)

With pushover I set the priority to 2.. but i can't find the equivalent with ntfy

@binwiederhier
Copy link
Owner

binwiederhier commented Sep 30, 2022

I've figured out how to ignore DND.. but how can i get it to ignore vibrate and play a sound (loud!)

I just tried and if I

  • set my phone to "Ring" (my OnePlus phone has a slider on the side of the phone)
  • enable DND
  • And set the "max priority" channel to "override DND"

It will play a sound even with DND.

Here's what that looks like. You can even set a custom ringtone for max priority items:
image

@binwiederhier
Copy link
Owner

I found this is a great sound for max priority: https://cdn.freesound.org/previews/607/607878_12946258-lq.mp3

@danmed
Copy link
Author

danmed commented Sep 30, 2022

I've figured out how to ignore DND.. but how can i get it to ignore vibrate and play a sound (loud!)

I just tried and if I

  • set my phone to "Ring" (my OnePlus phone has a slider on the side of the phone)
  • enable DND
  • And set the "max priority" channel to "override DND"

It will play a sound even with DND.

Here's what that looks like. You can even set a custom ringtone for max priority items: image

Hi,

thank you for your reply, but i don't want to take my phone off silent... (for a few reasons).. I was just wondering if NTFY could by pass the "silent" mode like pushover can.

@binwiederhier
Copy link
Owner

but i don't want to take my phone off silent...

Doesn't DND override all sounds and mutes them?

I was just wondering if NTFY could by pass the "silent" mode like pushover can.

I thought I had looked into that and decided it wasn't possible. But if Pushover does it, it must be possible ... It's a valid request.

@binwiederhier binwiederhier added enhancement New feature or request android-app ntfy Android app labels Sep 30, 2022
@danmed
Copy link
Author

danmed commented Sep 30, 2022

but i don't want to take my phone off silent...

Doesn't DND override all sounds and mutes them?

I was just wondering if NTFY could by pass the "silent" mode like pushover can.

I thought I had looked into that and decided it wasn't possible. But if Pushover does it, it must be possible ... It's a valid request.

Thank you for considering it.. here is the Pushover info : https://pushover.net/api#priority

@danmed
Copy link
Author

danmed commented Nov 13, 2022

I had to set up pushover on my phone again (new phone) and by default it wasn't bypassing my DND.. it turns out i'd had to alter some settings in the client and the main one is to play high priority alerts as through the alarm channel which bypasses DND / Silent mode.. maybe that will assist in progressing this one! (it also allows customising the sound played for high priority alerts)

@binwiederhier
Copy link
Owner

had to alter some settings in the client

If you could share the steps or screenshots that'd be helpful :-D

@danmed
Copy link
Author

danmed commented Nov 14, 2022

Screenshot_20221114-035739

This is just in the settings for the pushover app on Android... nothing else i can really share i'm afraid...

@binwiederhier
Copy link
Owner

What app is that from? Is that from Android, or in Pushover? It'd be more helpful if you could provide specific steps in Android. If it's a pushover setting, then don't bother, because I won't know what Pushover does under the hood.

@danmed
Copy link
Author

danmed commented Nov 17, 2022 via email

@binwiederhier binwiederhier added the in-progress 🏃 I'm working on this right now label Nov 28, 2022
@binwiederhier binwiederhier pinned this issue Nov 28, 2022
@binwiederhier
Copy link
Owner

I have managed to produce a looping alarm sound, even with DND enabled, and even when the phone is silent. I think I can make a similar toggle to the screenshot above. Working on this now.

@danmed
Copy link
Author

danmed commented Nov 28, 2022

I have managed to produce a looping alarm sound, even with DND enabled, and even when the phone is silent. I think I can make a similar toggle to the screenshot above. Working on this now.

Awesome!

@binwiederhier
Copy link
Owner

Alright I got something that reliably works. It is a little odd that it's not possible to configure the sound for this (yet), so I have to pick a sound. For my phone, the default notification sound (on repeat) works the best, but I don't know if that's ok with other phones.

I'm going to implement it this way and later, maybe if I ever get to #6, we can make this configurable.

@danmed
Copy link
Author

danmed commented Nov 29, 2022 via email

@binwiederhier
Copy link
Owner

Well, right now there is no toggle and the notification sound will literally not stop looping until you kill the app. So I'll let you know when I have something that is actually close to ready.

@binwiederhier
Copy link
Owner

Here's an .apk you can try: https://drive.google.com/file/d/11ZbKDPz4fz9RvvtAi1W3ylATr_L5AlOG/view?usp=share_link

(Be sure to back up your config using Settings -> Backup)

@binwiederhier
Copy link
Owner

@danmed Let me know if it generally works for you.

There has been a discussion on Discord/Matrix about this feature, and about whether or not to add a new priority level or a new flag to trigger this insistent behavior. Here are the options

  1. Add client-side toggle turn the normal "priority 5" behavior into the looping sound. No server side changes.
  2. Add new priority Priority: 6 (aka Priority: emergency), which will by default trigger the looping sound. There would be a cllient-side toggle to switch this behavior off. This is a little weird, because now the max priority is not the highest anymore. This requires server side changes, and may be a slightly breaking change for clients.
  3. Add Insistent: yes header, which will by default trigger the looping sound. There would be a client-side toggle to ignore this flag. This is a little off for something like Priority: min; Insistent: yes, because that would not alert at all. This requires server side changes.

Arguably, option 1+2 are kind of the same, because they both have a client-side toggle to turn the behavior off/on.

Thoughts?

@danmed
Copy link
Author

danmed commented Dec 4, 2022 via email

@binwiederhier
Copy link
Owner

No worries.

I have pretty much decided to either no release this feature at all, or just the same way that you suggested, with a new option that redefines priority 5 (option 1).

The problem is that I have not had much success getting people to try it. So far two people have tried. It worked for one, and not the other. So rather than releasing a brittle feature that no-one wants, I'd rather not release it at all.

Maybe I can get some more people to test once I have a few more features bundled into an RC.

image

@binwiederhier
Copy link
Owner

Current score:

  • Works: @binwiederhier on OnePlus 8 (Android 12) + Emulator (Android 12) + Emulator (Android 13), @cmeis (Android 12)
  • Doesn't work: @nwithan8 (Android 13)

@binwiederhier binwiederhier unpinned this issue Dec 6, 2022
@wunter8
Copy link
Contributor

wunter8 commented Dec 6, 2022

Works: @wunter8 on Pixel 5 (Android 13)

@binwiederhier
Copy link
Owner

binwiederhier commented Dec 8, 2022

This is now 100% implemented in binwiederhier/ntfy-android#49 -- It includes a per-subscription setting.

I'm going to wait with merging it until I get the Google Play stuff sorted out.

@binwiederhier
Copy link
Owner

I forgot to close this ticket. This was merged and released some time ago.

@jvandenbroek
Copy link

jvandenbroek commented Oct 24, 2023

Unfortunately this feature doesn't seem to work on my Poco F3 with MIUI 13. Log gives the following traceback:

1698136715441 2023-10-24 10:38:35.441 D NtfyNotifService Media player: Playing insistent alarm on alarm channel
1698136715446 2023-10-24 10:38:35.446 W NtfyNotifService Media player: Failed to play insistent alarm
Exception:
java.io.IOException: setDataSource failed.: status=0x80000000
        at android.media.MediaPlayer.nativeSetDataSource(Native Method)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1210)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1197)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1108)
        at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1028)
        at io.heckel.ntfy.msg.NotificationService.maybePlayInsistentSound(NotificationService.kt:453)
        at io.heckel.ntfy.msg.NotificationService.displayInternal(NotificationService.kt:115)
        at io.heckel.ntfy.msg.NotificationService.displayInternal$default(NotificationService.kt:90)
        at io.heckel.ntfy.msg.NotificationService.display(NotificationService.kt:32)
        at io.heckel.ntfy.msg.NotificationDispatcher.dispatch(NotificationDispatcher.kt:35)
        at io.heckel.ntfy.service.SubscriberService$onNotificationReceived$1.invokeSuspend(SubscriberService.kt:264)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

There is no option to make DND exemptions per notification on this ROM as shown by OP, really annoying and I will probably avoid MIUI in the future. However for some reason it does work even without this setting on the Home Assistant app by setting the channel to alarm_stream: https://companion.home-assistant.io/docs/notifications/critical-notifications/#android-alarm-stream

So if the same logic could be implemented in ntfy, I (and probably others) would be very happy :-) Thanks for the great work!

Edit: After some more testing I got it working with the built-in system notifications. Selecting a custom one in shared storage doesn't work when DND is enabled.

@juanrgm
Copy link

juanrgm commented Nov 30, 2023

Customizing the number of intervals and delay between sounds would be great.

In the meantime I had to add a delay to the end of the audio track with ffmpeg.

@gwlg-mjh
Copy link

gwlg-mjh commented Mar 7, 2024

Thanks, I was looking for a way to be able to override the silent mode so I can do a find my phone feature with Alexa and Home Assistant and not have to boot up a pc or laptop and do the Google/Samsung version. The only thing I would say is that when I originally saw this option in the settings it wasn't obvious that it would override the silent/vibrate setting on the phone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android-app ntfy Android app enhancement New feature or request in-progress 🏃 I'm working on this right now
Projects
None yet
Development

No branches or pull requests

6 participants