https://github.com/github30/own-push-notification
Homebrew push notifications without libraries.
https://github.com/github30/own-push-notification
firebase firebase-database firebase-realtime-database homebrew notifications push-notifications ubuntu windows-10
Last synced: about 2 months ago
JSON representation
Homebrew push notifications without libraries.
- Host: GitHub
- URL: https://github.com/github30/own-push-notification
- Owner: GitHub30
- License: mit
- Created: 2022-08-13T16:55:15.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-13T23:57:40.000Z (almost 4 years ago)
- Last Synced: 2026-04-04T07:33:20.995Z (3 months ago)
- Topics: firebase, firebase-database, firebase-realtime-database, homebrew, notifications, push-notifications, ubuntu, windows-10
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Homebrew push notifications without libraries.
## Listen
### Windows
```powershell
$HttpWebRequest = [System.Net.HttpWebRequest]::Create('https://rppico-default-rtdb.asia-southeast1.firebasedatabase.app/msg.json')
$HttpWebRequest.Accept = 'text/event-stream'
$ResponseStream = $HttpWebRequest.GetResponse().GetResponseStream()
$StreamReader = [System.IO.StreamReader]::new($ResponseStream)
while (($line = $StreamReader.ReadLine()) -ne $null)
{
if (-! $line.StartsWith('data: {')){ continue }
$ToastText01 = [Windows.UI.Notifications.ToastTemplateType, Windows.UI.Notifications, ContentType = WindowsRuntime]::ToastText01
$TemplateContent = [Windows.UI.Notifications.ToastNotificationManager,Windows.UI.Notifications, ContentType = WindowsRuntime]::GetTemplateContent($ToastText01)
$TemplateContent.SelectSingleNode('//text[@id="1"]').InnerText = ($line.Substring(6) | ConvertFrom-Json).data
$AppId = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).Show($TemplateContent)
}
$StreamReader.Close() > $null
$ResponseStream.Close() > $null
```
### Mac
```bash
curl https://rppico-default-rtdb.asia-southeast1.firebasedatabase.app/msg.json -H Accept:text/event-stream --no-buffer \
| grep '^data: {' --line-buffered \
| while read line; do osascript -e 'display notification "'"${line:26:-2}"'"'; done
```
### Linux
```bash
wget --header Accept:text/event-stream -qO- https://rppico-default-rtdb.asia-southeast1.firebasedatabase.app/msg.json \
| grep '^data: {' --line-buffered \
| while read line; do notify-send "${line:26:-2}"; done
```
## Publish
### Windows
```powershell
Invoke-WebRequest -Method PUT -Body ([System.Text.Encoding]::UTF8.GetBytes("`"🕊$(date -Format yyyy-MM-ddTHH:mm:ss.fff)`"")) https://rppico-default-rtdb.asia-southeast1.firebasedatabase.app/msg.json
```
### Mac
```bash
curl -X PUT -d '"🐥'$(date --iso-8601=ns)'"' https://rppico-default-rtdb.asia-southeast1.firebasedatabase.app/msg.json
```
### Linux
```bash
wget --method PUT --body-data '"🐧'$(date --iso-8601=ns)'"' -qO- https://rppico-default-rtdb.asia-southeast1.firebasedatabase.app/msg.json
```
## Endpoint
Open your [Firebase console](https://console.firebase.google.com/) and copy it


# References
https://firebase.google.com/docs/reference/rest/database#section-streaming