Skip to content

viktorholk/push-notifications-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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 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!

animated

Installation

Android App

You can download the Android app through Google Play or download the latest apk from the releases.

Connect

In the configuration tab type in the /events endpoint on your server

You can find the IP-address in the server log

animated

Server

If you haven't already, install Node.

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

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 No
Response

Created 201

Get All Notifications

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

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

Issues

Please report issues using GitHub's issues tab.

License

Push Notifications API is under the MIT LICENSE.