mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-15 15:45:49 -06:00
[GH-ISSUE #199] Web Push support #157
Labels
No labels
ai-generated
android-app
android-app
android-app
build
build
dependencies
docs
enhancement
enhancement
in-progress 🏃
ios
prio:low
prio:low
pull-request
question
server
server
unified-push
web-app
website
🔒 security
🔥 HOT
🪲 bug
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/ntfy#157
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ross-rosario on GitHub (Apr 6, 2022).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/199
This is a very neat tool. It's however missing a single feature that would make it a complete alternative for AWS/Azure notification solutions, and that is Push API support https://developer.mozilla.org/en-US/docs/Web/API/Push_API.
Any plans on enabling the server to push events to web clients? The goal is to get around the current limitation of the UI client, that needs to remain open to receive events.
@binwiederhier commented on GitHub (Apr 6, 2022):
I like the idea, and I vaguely remember looking into this a while ago. I don't quite know why I didn't pursue it further. I'll investigate it eventually.
@binwiederhier commented on GitHub (Apr 6, 2022):
To be fair though, I think that's perfectly reasonable, as you'll want to click on the notification anyway when it arrives. I just pin it like I do with Gmail and WhatsApp and such.
@ross-rosario commented on GitHub (Apr 6, 2022):
With Gmail and Whatsapp, you can receive a desktop notification (think the upper-right corner Mac OS bubble), and once clicked, the website will open in a browser tab. At least that's the behavior I'm currently pursuing.
@binwiederhier would you please provide some pointers on where such a feature could be plugged in the Ntfy codebase? is there any example I could follow? Thanks!
@ross-rosario commented on GitHub (Apr 6, 2022):
Basically what I'm aiming to accomplish, is sending notifications to browsers, even when the website is closed, and only to the browsers that have subscribed to a certain topic. ie pubsub + Notifications API (which ntfy excels at) + Push API instead of Web Sockets or HTTP Streams.
@binwiederhier commented on GitHub (Apr 6, 2022):
I am on Ubuntu, so I can't verify that. Can you maybe post a screenshot?
This is tricky. I don't know anything about the server side implementation for the Push API. I don't know if it's based on HTTP/WebSockets/grpc/etc. I tried to look for libraries, but there are no popular libraries for Go, and the Push API seems like a more or less abandoned (or at least not widely used) standard, at least that's what it seemed in my 2min research.
As for where to plug it in: https://github.com/binwiederhier/ntfy/blob/main/server/server.go#L185-L215 -- My assumption is that it's another server on a different port. I honestly don't know though, because I can't for the life of me find out what protocol it uses.
Yeah I understand :-D
@binwiederhier commented on GitHub (Apr 6, 2022):
Okay I read parts of the Web Push API spec, and it looks like I was wrong. Apparently the browsers provide a push service, so Firefox/Mozilla would provide
https://updates.push.services.mozilla.com/wpushfor instance, and the ntfy server would just have to forward the push to that.So there is no additional server running that the browser has to connect to. It's all through Mozilla or Google's servers basically. I think in that case it's more similar to Firebase, in that we simply forward messages to the push service (see https://github.com/binwiederhier/ntfy/blob/main/server/server.go#L421). The crypto of the Web Push API is quite complex, which is why I really would want to use a library for it.
I think I may do this because it's fun. But I'm not guaranteeing any timelines.
@karmanyaahm commented on GitHub (Apr 8, 2022):
https://github.com/SherClockHolmes/webpush-go/ is a pretty good and popular library for this. I think the main obstacle (iirc the last time I looked at the firebase code for ntfy), would be that right now, Firebase keeps track of which device is subscribed to which topic, whereas with WebPush, ntfy would have to keep track of endpoint->topic mappings.
Another advantage of implementing this would be that in addition to ntfy-over-firebase, ntfy-over-unifiedpush would become possible (since WebPush and UnifiedPush are compatible). Self-hosted servers could also have push using some gateways.
@sfkpmr commented on GitHub (Apr 29, 2022):
Could you point me to how to do this? If I understand you correctly it'll keep me notified if something happens without needing a tab with ntfy open?
@binwiederhier commented on GitHub (Apr 29, 2022):
Right click on the tab -> Pin tab
@binwiederhier commented on GitHub (Apr 29, 2022):
This does need the tab open though, but the tab is pinned, so it's just the small icon. There is no way to receive notifications without an open tab, unless you use the ntfy CLI: https://ntfy.sh/docs/subscribe/cli/#subscribe-to-topics
@sfkpmr commented on GitHub (Apr 29, 2022):
Gotcha, hopefully push can help with it.
@mmojadad commented on GitHub (Feb 5, 2023):
VAPID, which stands for Voluntary Application Server Identity, is a new way to send and receive website push notifications. Your VAPID keys allow you to send web push campaigns without having to send them through a service like Firebase Cloud Messaging (or FCM)
@pinpox commented on GitHub (May 26, 2023):
Any news on this? I looked into how this would be implemened but wasn't able to find any simple tutorials of how to do this in go. i've seen more and more web pages sending these notifications, any hints on how you would add this?
If it's not a huge task I might consider preparing a PR
@nimbleghost commented on GitHub (May 26, 2023):
@pinpox I just started working on this in #751, there are still some open questions about the UX around subscribing to background notifications.
There's also some technical stuff left - handling syncing from accounts and handling re-subscribing if the subscription is broken for whatever reason, and more testing on iOS (notifications work, the PWA needs to be tested more).
@icxes commented on GitHub (May 27, 2023):
I've been testing the web push from #751 for a bit now, and it's been working great for me and the few other people that use my server. I was hoping this feature would be implemented soon, so big thanks to you for your work on it @nimbleghost!
@helmut72 commented on GitHub (May 29, 2023):
@nimbleghost
This would be fantastic if it works on iOS. How can I create a Docker image with your patch?
@nimbleghost commented on GitHub (May 29, 2023):
@helmut72 I also added #754, so you can simply checkout the branch run it from there.
e.g. locally: https://docs.ntfy.sh/develop/#build-a-docker-image-only-for-linux
or if using it in a compose file:
Please be aware that it's a WIP and I've already changed the db schema without migrations since it isn't released yet, so if you run it you may have to delete your
web-push-subscriptions-filedatabase when pulling in updates. Service workers / application caching is also being worked on, which may result in odd behaviour and need a manual unregistration if something breaks (though so far hasn't been a problem).@helmut72 commented on GitHub (May 29, 2023):
@nimbleghost thanks, I have just used your repo:
https://github.com/nimbleghost/ntfy
But webpush doesn't work. Added my webapp to home screen, check if notifications are enabled for this webapp, but I see the message "notification won't be supported"
@nimbleghost commented on GitHub (May 29, 2023):
@helmut72 are you using the correct branch? It's this one: https://github.com/nimbleghost/ntfy/tree/pwa
but if you are you also need to be serving the web app over https, and have the right config values set (see https://github.com/nimbleghost/ntfy/blob/pwa/docs/config.md#config-options and look for the web push options)
@helmut72 commented on GitHub (May 29, 2023):
@nimbleghost Thanks, I've overseen that required config options. Great, now it works. I just miss that sound/beep and in the notification menu, ntfy is there twice. One entry with, other without sound.
@nimbleghost commented on GitHub (May 29, 2023):
@helmut72 Nice! Not sure which commit you have, but the latest changes should have both the sound and double notifications fixed. If the sound still doesn't work, can you check your browser console's error messages and tell me what browser you're testing with?
@mmojadad commented on GitHub (May 29, 2023):
I am interest to have such features on web push
@binwiederhier commented on GitHub (May 29, 2023):
@mmojadad you've got the wrong tool here. ntfy is a privacy focused push notification service. Not a marketing platform. We will not add features to collect gps data or any user data, or support for campaigns.
@mmojadad commented on GitHub (May 29, 2023):
@ binwiederhier Thanks for your clearifications.
@helmut72 commented on GitHub (May 29, 2023):
I have played with a commit from today lunch time. Now I've build it about 30min ago. Deleted everything and ntfy isn't there twice in the notification settings. In this single setting there is now no sound entry:
From the menu in the ntfy webapp, where I can choose the sound, sound now plays on my iPhone (and iPad):
But this feels more like a very small sound stream (like from Youtube) and not like a notification sound, because it's also there in the global player of iOS:
@nimbleghost commented on GitHub (May 29, 2023):
@helmut72 Ah you meant for the notification - as far as I can see iOS doesn't support sounds for web push whatsoever at the moment.
@helmut72 commented on GitHub (May 29, 2023):
@nimbleghost Ok, I was unaware of this. Thanks for the info. Then it looks good for me.
@binwiederhier commented on GitHub (Jun 1, 2023):
I am closing this in favor of #346, which is (essentially) a duplicate. @nimbleghost is working on this right now.