binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
18.47k stars 727 forks source link

Expiration date of messages #389

Open 1dancook opened 2 years ago

1dancook commented 2 years ago

I saw on the readme about your baby and know your kiddo has probably just been born. Congrats! Cherish the time... your baby will change very fast.

I have two question related to messages expiring:

  1. Is it possible to specify an expiration date? I scoured around trying to find if there was some expiration date that could be added to messages but couldn't find anything.

  2. Do messages automatically expire right now? (Or does ntfy.sh delete messages older than X days old?) If so, how long do they last?

Cheers!

binwiederhier commented 2 years ago

probably just been born

Not yet :-D

Is it possible to specify an expiration date? I scoured around trying to find if there was some expiration date that could be added to messages but couldn't find anything.

You cannot set an expiration date for a notification. I like the idea though, and I can't believe that we don't have a ticket for it. I know we've discussed it before on the Discord. We'd have to add a new field expiry (or expires or expiration), and then provide a way for the Android/web/iOS app to remove the notification (and delete it?) at the expiry date.

Should it be fully deleted, or should we just cancel the notification?

Also: Canceling a notification is not possible on the web. Only on Android (and I believe iOS).

Do messages automatically expire right now? (Or does ntfy.sh delete messages older than X days old?) If so, how long do they last?

Notifications are automatically deleted from the server after 12h (globally configurable server-side), and are deleted based on whatever you configure in the Android app (1 week by default, iirc). Android notifications are never canceled based on time, only if you tap them or navigate to the topic screen.

1dancook commented 2 years ago

Notifications are automatically deleted from the server after 12h (globally configurable server-side)

Got it. That answers that question.


For setting expiration, the questions you posed show it is a little more involved than I had thought.

Maybe a potential use case could help to draw it out?

Situation: A script runs on a home computer to check the weather and post to ntfy if it is going to rain. The user will get notified on his smartphone. On a Monday the computer posts a message at 9am. The user was busy in a meeting all morning and didn't check his phone until lunch.

That information has a natural expiration-- it is (probably) a useless notification after a certain amount of time has passed. The user checking his phone at lunch to see a message "it's going to rain" might later check if his script is working properly when he sees clear skies!

Should it be fully deleted, or should we just cancel the notification?

In my head expired means throw it out! If a server can be configured to keep posts indefinitely, then maybe it makes sense to at least have the option where a post could expire and be deleted permanently based on a user decision. The flip side of that would be the ability to set a post to never expire (thus never get deleted) even though the server is set to wipe messages after X duration.

provide a way for the Android/web/iOS app to remove the notification

I'm not sure how that works to cancel a notification. Does it mean that a notification on a home screen can be taken away? That sounds fitting.

If the notification would persist in the app, it could be good to have some visual cue to let the user know it is expired (a different color, or something)


probably just been born Not yet :-D

If it's the first baby, they often come late. Nothing to worry about. Just fattening up some more and contemplating a good exit strategy!! 🤣

Lots of anticipation... I hope and trust all will go well for both mother and baby.

pcgeek86 commented 1 year ago

I would love to see the ability to expire notifications! As you're probably aware, notifications can easily be abused, and it would be nice to set them to automatically expire.

This would be especially useful so that you can set up periodic (ie. 15-minute), informational notifications, but if you put your phone down for a while (hours), the notifications won't get all backed up.

It looks like Android has the ability to "cancel" notifications, using NotificationManager.cancel.

https://stackoverflow.com/questions/23874203/create-an-android-notification-with-expiration-date

risacher commented 1 year ago

In terms of canceling notifications on web - even if you can't cancel the notification popup, you could remove expired notifications in the web UI. (I keep ntfy.sh as a pinned tab.)

Both my current applications that use ntfy send (at least) daily notifications to let me know they're still alive. As such I don't care if they were alive two days ago - only the most recent notification is meaningful. An expiration feature would help with this.

osering commented 10 months ago

Such messages would remind self-destructing/disappearing messages messages of Signal messenger, to enhance privacy