[GH-ISSUE #91] Max/High priority notifications should be able to override DND #73

Closed
opened 2026-05-07 00:19:32 +02:00 by BreizhHardware · 6 comments
Originally created by @binwiederhier on GitHub (Jan 12, 2022). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/91 https://stackoverflow.com/questions/31862753/android-how-to-turn-on-do-not-disturb-dnd-programmatically
Author
Owner

@12nick12 commented on GitHub (Jan 17, 2022):

I second this. This would be awesome.

<!-- gh-comment-id:1014090034 --> @12nick12 commented on GitHub (Jan 17, 2022): I second this. This would be awesome.
Author
Owner

@binwiederhier commented on GitHub (Apr 14, 2022):

I am dabbling with this now. I'm able to turn DND off/on globally, but I don't really want to do that. I just want to decide which notification make a sound, and which ones don't.

<!-- gh-comment-id:1098649702 --> @binwiederhier commented on GitHub (Apr 14, 2022): I am dabbling with this now. I'm able to turn DND off/on globally, but I don't really want to do that. I just want to decide which notification make a sound, and which ones don't.
Author
Owner

@binwiederhier commented on GitHub (Apr 14, 2022):

This is quite fascinating but also interesting.

For each of the 5 priorities, I create an Android NotificationChannel, for which I can set setBypassDnd flag. However, I can only set that if I have a certain permission, for which the user has to manually toggle a setting in the Android UI. That wouldn't be a problem, except that a NotificationChannel, once created, cannot be updated ...............

Rubber ducking apparently works, even when typing it out 🦆 🦆 🦆

Looks like channels can be updated and when the permission to edit DND has been granted, setting setBypassDnd after the fact on an existing channel works.

I think I can work with this 🥳

<!-- gh-comment-id:1098663920 --> @binwiederhier commented on GitHub (Apr 14, 2022): This is quite fascinating but also interesting. For each of the 5 priorities, I create an Android `NotificationChannel`, for which I can set `setBypassDnd` flag. However, I can only set that if I have a certain permission, for which the user has to manually toggle a setting in the Android UI. That wouldn't be a problem, except that a `NotificationChannel`, once created, ~cannot be updated~ ............... [Rubber ducking](https://en.wikipedia.org/wiki/Rubber_duck_debugging) apparently works, even when typing it out :duck: :duck: :duck: Looks like channels can be updated and when the permission to edit DND has been granted, setting `setBypassDnd` after the fact on an existing channel works. I think I can work with this :partying_face:
Author
Owner

@binwiederhier commented on GitHub (Apr 14, 2022):

So I dabbled (https://github.com/binwiederhier/ntfy-android/pull/25), but we decided via Discord that we'll not programmatically change the DND override for individual channels in the app. Instead, I'll just make a menu item to "Override DND, sound and vibration" which will open the Android "Notification Settings" dialog. I'll also write some docs.

Screenshot_20220414-085007

<!-- gh-comment-id:1099277204 --> @binwiederhier commented on GitHub (Apr 14, 2022): So I dabbled (https://github.com/binwiederhier/ntfy-android/pull/25), but we decided via Discord that we'll not programmatically change the DND override for individual channels in the app. Instead, I'll just make a menu item to "Override DND, sound and vibration" which will open the Android "Notification Settings" dialog. I'll also write some docs. ![Screenshot_20220414-085007](https://user-images.githubusercontent.com/664597/163417952-86ee46d0-c7c5-4311-94d7-c9917a7924d1.jpg)
Author
Owner

@binwiederhier commented on GitHub (Apr 14, 2022):

220414 13-01-08 Selection 001

Fixed with this^^, but I'll add some documentation too, so I'll leave it open until then.

<!-- gh-comment-id:1099411805 --> @binwiederhier commented on GitHub (Apr 14, 2022): ![220414 13-01-08 Selection 001](https://user-images.githubusercontent.com/664597/163437989-9865514e-e68e-41cd-bc8d-cd79b010de2a.png) Fixed with this^^, but I'll add some documentation too, so I'll leave it open until then.
Author
Owner

@binwiederhier commented on GitHub (Apr 15, 2022):

Added docs for this: github.com/binwiederhier/ntfy@06fd7327de

<!-- gh-comment-id:1100319766 --> @binwiederhier commented on GitHub (Apr 15, 2022): Added docs for this: https://github.com/binwiederhier/ntfy/commit/06fd7327de5db7a6df4aa95ee762221c063ac77b
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#73
No description provided.