This site requires JavaScript to work. Either you have disabled JavaScript in your browser settings or the script failed to load.
Keep in mind that this is just a personal project. I'll try to keep it online, but I make no guarantees that it'll be online next year or even next week.
With this site you can generate a unique URL which can be used to send push notifications to your device. Click the button below to generate a URL for this device.
Make sure your browser (the actual .exe
, .app
, etc.) has permissions to send notifications at the OS level. It's not enough to accept the "notifications.linus.onl wants to send notifications" pop-up; your browser also has to have those permissions.
Now that you have a token that's unique to your device, you can use it by sending a post request. Below is an example using curl
.
curl https://notifications.linus.onl/api/send-notification/token \
--request POST \
--header "Content-Type: application/json" \
--data '{
"title": "your title",
"message": "your message",
"url": "http://example.com"
}'
Here is an example using Python and requests, if that's more your cup of tea.
import requests
token = "your token"
data = {
"title": "your title", # This is required
"message": "your message", # This is optional
"url": "your url", # Also optional
}
response = requests.post(f"https://notifications.linus.onl/api/send-notification/{token}", json=data)
response.raise_for_status()
print(response.json())
Note that a response from a /api
endpoint are only guaranteed to be valid JSON if it has a successful status code. The call to raise_for_status
is crucial in the above example.
This project works using the Web Push protocol and a service worker to send notifications. Much of the code is based on the Chrome DevRel team's excellent guide.
I was inspired by @h43z who made basically the exact same thing but better. I did, however, decide not to read any of their code before writing my own implementation. I figured it would be a better learning experience if I didn't just blindly copy-paste whatever they'd done. I do have a suspicion that their implementation is much more robust, though.