notification icons

This commit is contained in:
Hunter Kehoe 2022-07-16 13:31:03 -06:00
parent cbcd0e3f0d
commit d519fd999b
14 changed files with 197 additions and 13 deletions

View file

@ -2349,6 +2349,84 @@ Here's an example showing how to attach an APK file:
<figcaption>File attachment sent from an external URL</figcaption>
</figure>
## Icons
_Supported on:_ :material-android:
You can include an icon that will appear next to the text of the notification. Simply pass the `X-Icon` header or query
parameter (or its alias `Icon`) to specify the URL that the icon is located at. The client will automatically download
the icon (up to 300KB) and show it in the notification. Only jpeg and png images are supported at this time.
Here's an example showing how to include an icon:
=== "Command line (curl)"
```
curl \
-X POST \
-H "Icon: https://ntfy.sh/docs/static/img/ntfy.png" \
ntfy.sh/customIcons
```
=== "ntfy CLI"
```
ntfy publish \
--icon="https://ntfy.sh/docs/static/img/ntfy.png" \
customIcons
```
=== "HTTP"
``` http
POST /customIcons HTTP/1.1
Host: ntfy.sh
Icon: https://ntfy.sh/docs/static/img/ntfy.png
```
=== "JavaScript"
``` javascript
fetch('https://ntfy.sh/customIcons', {
method: 'POST',
headers: { 'Icon': 'https://ntfy.sh/docs/static/img/ntfy.png' }
})
```
=== "Go"
``` go
req, _ := http.NewRequest("POST", "https://ntfy.sh/customIcons", file)
req.Header.Set("Icon", "https://ntfy.sh/docs/static/img/ntfy.png")
http.DefaultClient.Do(req)
```
=== "PowerShell"
``` powershell
$uri = "https://ntfy.sh/customIcons"
$headers = @{ Icon="https://ntfy.sh/docs/static/img/ntfy.png" }
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -UseBasicParsing
```
=== "Python"
``` python
requests.put("https://ntfy.sh/customIcons",
headers={ "Icon": "https://ntfy.sh/docs/static/img/ntfy.png" })
```
=== "PHP"
``` php-inline
file_get_contents('https://ntfy.sh/customIcons', false, stream_context_create([
'http' => [
'method' => 'PUT',
'header' =>
"Content-Type: text/plain\r\n" . // Does not matter
"Icon: https://ntfy.sh/docs/static/img/ntfy.png",
]
]));
```
Here's an example of how it will look on Android:
<figure markdown>
![file attachment](static/img/android-screenshot-icon.png){ width=500 }
<figcaption>Custom icon from an external URL</figcaption>
</figure>
## E-mail notifications
_Supported on:_ :material-android: :material-apple: :material-firefox:
@ -2804,6 +2882,7 @@ and can be passed as **HTTP headers** or **query parameters in the URL**. They a
| `X-Actions` | `Actions`, `Action` | JSON array or short format of [user actions](#action-buttons) |
| `X-Click` | `Click` | URL to open when [notification is clicked](#click-action) |
| `X-Attach` | `Attach`, `a` | URL to send as an [attachment](#attachments), as an alternative to PUT/POST-ing an attachment |
| `X-Icon` | `Icon` | URL to use as notification [icon](#icons) |
| `X-Filename` | `Filename`, `file`, `f` | Optional [attachment](#attachments) filename, as it appears in the client |
| `X-Email` | `X-E-Mail`, `Email`, `E-Mail`, `mail`, `e` | E-mail address for [e-mail notifications](#e-mail-notifications) |
| `X-Cache` | `Cache` | Allows disabling [message caching](#message-caching) |

View file

@ -13,6 +13,7 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
* Polling is now done with `since=<id>` API, which makes deduping easier ([#165](https://github.com/binwiederhier/ntfy/issues/165))
* Turned JSON stream deprecation banner into "Use WebSockets" banner (no ticket)
* Move action buttons in notification cards ([#236](https://github.com/binwiederhier/ntfy/issues/236), thanks to [@wunter8](https://github.com/wunter8))
* Icons can be set for each individual notification ([#126](https://github.com/binwiederhier/ntfy/issues/126), thanks to [@wunter8](https://github.com/wunter8))
**Bugs:**
@ -41,12 +42,12 @@ Thank you to [@wunter8](https://github.com/wunter8) for proactively picking up s
* `ntfy user` commands don't work with `auth_file` but works with `auth-file` ([#344](https://github.com/binwiederhier/ntfy/issues/344), thanks to [@Histalek](https://github.com/Histalek) for reporting)
* Ignore new draft HTTP `Priority` header ([#351](https://github.com/binwiederhier/ntfy/issues/351), thanks to [@ksurl](https://github.com/ksurl) for reporting)
* Delete expired attachments based on mod time instead of DB entry to avoid races (no ticket)
* Icons can be set for each individual notification ([#126](https://github.com/binwiederhier/ntfy/issues/126), thanks to [@wunter8](https://github.com/wunter8))
**Documentation:**
* Fix some PowerShell publish docs ([#345](https://github.com/binwiederhier/ntfy/pull/345), thanks to [@noahpeltier](https://github.com/noahpeltier))
-->
## ntfy server v1.27.2
Released June 23, 2022

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB