Package io.github.pimak.ntfy.core
Interface NtfyAction
- All Known Implementing Classes:
NtfyAction.Broadcast,NtfyAction.Http,NtfyAction.View
A single ntfy notification action button, modeled as a sealed hierarchy so each action type
carries only the fields it needs (mirroring the
AuthMode pattern). Actions are rendered
into ntfy's Actions HTTP header by NtfyActionSerializer; ntfy allows at most three
per notification.
All three ntfy action types are modeled: NtfyAction.View (open a URL — e.g. a dashboard or log
link), NtfyAction.Http (fire an HTTP request — e.g. an acknowledge webhook, with optional typed
NtfyAction.HttpHeaders), and NtfyAction.Broadcast (send an Android broadcast intent with optional typed
NtfyAction.BroadcastExtras — only actioned by ntfy's Android app).
label and url are validated non-blank at construction: a malformed action is a
programming error surfaced immediately, never a silent runtime publish failure.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordSends an Android broadcast intent when tapped (only actioned by ntfy's Android app).static final recordstatic final recordSends an HTTP request tourlwhen tapped.static final recordstatic final recordOpensurlin the browser/app when the action button is tapped. -
Method Summary
Modifier and TypeMethodDescriptionstatic NtfyAction.Broadcastbroadcast(String label, NtfyAction.BroadcastExtra... extras) Abroadcastaction sending ntfy's default intent, with optionalextras.static NtfyAction.Broadcastbroadcast(String label, String intent, boolean clear, NtfyAction.BroadcastExtra... extras) Abroadcastaction sendingintent(blank uses ntfy's default) with an explicitclearflag dismissing the notification on tap, plus optionalextras.static NtfyAction.Broadcastbroadcast(String label, String intent, NtfyAction.BroadcastExtra... extras) Abroadcastaction sendingintent(blank uses ntfy's default), with extras.static NtfyAction.HttpAnhttpaction sending a GET tourlwhen tapped.static NtfyAction.HttpAnhttpaction sendingmethod(with optionalbody) tourl.static NtfyAction.Httphttp(String label, String url, String method, String body, boolean clear, NtfyAction.HttpHeader... headers) Anhttpaction ashttp(String, String, String, String, HttpHeader...)but with an explicitclearflag dismissing the notification on tap.static NtfyAction.HttpAnhttpaction sendingmethod(with optionalbody) tourl, carrying the given requestheaders(e.g.label()The button label shown in the notification.static NtfyAction.ViewAviewaction openingurlwhen tapped.static NtfyAction.ViewAviewaction openingurl;cleardismisses the notification on tap.
-
Method Details
-
label
String label()The button label shown in the notification. -
view
Aviewaction openingurlwhen tapped. -
view
Aviewaction openingurl;cleardismisses the notification on tap. -
http
Anhttpaction sending a GET tourlwhen tapped. -
http
Anhttpaction sendingmethod(with optionalbody) tourl. -
http
static NtfyAction.Http http(String label, String url, String method, String body, NtfyAction.HttpHeader... headers) Anhttpaction sendingmethod(with optionalbody) tourl, carrying the given requestheaders(e.g.Authorization). -
http
static NtfyAction.Http http(String label, String url, String method, String body, boolean clear, NtfyAction.HttpHeader... headers) Anhttpaction ashttp(String, String, String, String, HttpHeader...)but with an explicitclearflag dismissing the notification on tap. -
broadcast
Abroadcastaction sending ntfy's default intent, with optionalextras. -
broadcast
static NtfyAction.Broadcast broadcast(String label, String intent, NtfyAction.BroadcastExtra... extras) Abroadcastaction sendingintent(blank uses ntfy's default), with extras. -
broadcast
static NtfyAction.Broadcast broadcast(String label, String intent, boolean clear, NtfyAction.BroadcastExtra... extras) Abroadcastaction sendingintent(blank uses ntfy's default) with an explicitclearflag dismissing the notification on tap, plus optionalextras.
-