Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viktorholk/push-notifications-api
📱 Send Instant Push Notifications to your Android Phone through a REST-API.
https://github.com/viktorholk/push-notifications-api
android java notifications push-notifications rest-api server-side-events
Last synced: 6 days ago
JSON representation
📱 Send Instant Push Notifications to your Android Phone through a REST-API.
- Host: GitHub
- URL: https://github.com/viktorholk/push-notifications-api
- Owner: viktorholk
- License: mit
- Created: 2020-09-30T13:35:39.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-07T19:59:17.000Z (about 2 months ago)
- Last Synced: 2024-12-10T05:41:56.752Z (15 days ago)
- Topics: android, java, notifications, push-notifications, rest-api, server-side-events
- Language: Java
- Homepage: https://play.google.com/store/apps/details?id=com.viktorholk.apipushnotifications
- Size: 529 KB
- Stars: 52
- Watchers: 5
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Push Notifications API# About
Push Notifications API is a simple Android app for displaying notifications on your phone through a REST-API. Using a Node server with server sent events.
It is a tool for developers that need a easy way to post notifications to their phone. The application requires an API to handle all the notifications. There is a working example of a Node server in the [server](https://github.com/viktorholk/push-notifications-api/tree/main/server) folder that works with the Android app.
The application is great for IoT (Internet of Things). You could for example post a notification to your phone every time your garden needs watering when a sensor has detected the level of soil moisture to be low. The possibilites are up to you!
# Installation
## Android App
You can download the Android app through [Google Play](https://play.google.com/store/apps/details?id=com.viktorholk.apipushnotifications) or download the latest apk from the [releases](https://github.com/viktorholk/push-notifications-api/releases).### Connect
In the configuration tab type in the `/events` endpoint on your server
You can find the IP-address in the server log
## Server
If you haven't already, install [Node](https://nodejs.org/en/download/prebuilt-binaries).
### Clone the Project```
git clone [email protected]:viktorholk/push-notifications-api.git
cd push-notifications-api
npm i
```
### Start the Server
```
npm start
```The app will by default run on port 3000 and the endpoint for the notification events are ``/events``
The port can be changed in the ``server/.env`` file
### API Reference
Replace `127.0.0.1:3000` with your IP and port
#### Push Notification
```http
POST http://127.0.0.1:3000
```
Example Curl
````
curl '127.0.0.1:3000' \
--header 'Content-Type: application/json' \
--data '{
"title": "Foo Bar Baz!",
"message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"url": "http://example.com",
"icon": "suitcase.png",
"color": "#1554F0"
}'
````|Property|Type|Description|Required|
|---|---|---|---|
|title|String|The title of the notification|**Yes**|
|message|String|The longer text that will be included in the notification|No|
|url|String|Open the URL on notifcation press|No|
|icon|String|24x24 icon file located in `server/src/icons`|No|
|color|String|Customize the notification color. See supported [colors](https://developer.android.com/reference/android/graphics/Color#parseColor(java.lang.String)) |No|##### Response
`Created 201`#### Get All Notifications
```http
GET http://127.0.0.1:3000
```##### Response
````
[
{
"title": "Foo Bar Baz!",
"message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"url": "http://example.com",
"icon": "base64encoded...",
"color": "#1554F0"
},
...
]
````#### Get The Latest Notification
```http
GET http://127.0.0.1:3000/latest
```##### Response
````
{
"title": "Foo Bar Baz!",
"message": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"url": "http://example.com",
"icon": "base64encoded...",
"color": "#1554F0"
}
````## Common Asked Questions
Notifications are not showing up
Make sure notifications are enabled in your settings
Settings > Notifications > App notifications
![image](https://github.com/user-attachments/assets/12685adf-7a74-4915-bda6-045175031afb)
## Issues
Please report issues using [GitHub's issues tab](https://github.com/viktorholk/push-notifications-api/issues).
## License
Push Notifications API is under the [MIT LICENSE](LICENSE).