Is there any way I can send a notification to my android phone using a http post request without using pushover? For my CCTV project I would like to be able to get my Raspberry Pi, which I may note is running the Security Camera itself, to run a http POST request which then triggers a notification on my phone. I have heard about Pushover however I would not like to have to pay for a service.
-
If you are just connecting with a single (and known) device on your own network the devices could use sockets. https://developer.android.com/reference/java/net/Socket.html --- and maybe look at this -- http://androidsrc.net/android-client-server-using-sockets-client-implementation/ – Barns Jul 12 '17 at 21:54
2 Answers
you can use IFTTT.com with the WebHook action. Each time it receives a Web Request it will show a Notification on your Phone. you even can use Values to make custom notifications depending on your post. I used Node-Red on the raspberry pi to make these HTTP-Posts but im sure there are better ways.

- 354
- 2
- 15
Is there any way I can send a notification to my android phone using a http post request
Yes, it's possible. You can send messages to specific devices using HTTP POST requests as described here.
In order to be able to send FCM messages you have to implement the FCM HTTP server protocol as described here. For your convenience, you can use a Rest Client of your choice e.g. Postman to send notifications using the FCM HTTP server protocol.
If you want to use Raspberry Pi, then you can send notifications using curl as follows:
curl -X POST \
https://fcm.googleapis.com/fcm/send \
-H 'authorization: key=YOUR_SERVER_KEY' \
-H 'content-type: application/json' \
-d '{
"to" : "DEVICE_REGISTRATION_TOKEN",
"notification" : {
"body" : "body goes here",
"title" : "title goes here",
"icon" : "myicon"
}
}'
As you probably already know, with FCM you can send two types of messages to clients, Notification and Data messages. More about the FCM messages can be found here.

- 926
- 7
- 11
-
Sorry I'm kind of new to the whole curl thing. How can I execute the curl command through terminal(on Linux) in one line... Or can I make it a file on the device and the command would be run (file).sh? Would that work? – Void Raider Jul 13 '17 at 22:44
-
Just copy and paste the command I posted above. Don't forget to replace your server key and the device registration token – kws Jul 13 '17 at 23:22
-
For fcm don't I need to port forward some ports to accept fcm notifications... Which wouldn't really work on the go. Because I can't really port forward on a cafe WiFi for example... – Void Raider Jul 13 '17 at 23:35
-
You just have to send a simple HTTP POST request using your Raspberry Pi. It has nothing to do with port forwarding. Try to copy and paste the command I posted above to your terminal, add your server key and the device registration token and you're done. – kws Jul 13 '17 at 23:48
-
1Got this back... curl: (1) Protocol " https" not supported or disabled in libcurl curl: (6) Couldn't resolve host ' -H' curl: (3) Illegal port number curl: (6) Couldn't resolve host ' -H' curl: (3) Illegal port number curl: (6) Couldn't resolve host ' -d' curl: (3) [globbing] nested brace in column 171 – Void Raider Jul 14 '17 at 00:11
-
https://stackoverflow.com/questions/6884669/curl-1-protocol-https-not-supported-or-disabled-in-libcurl https://serverfault.com/questions/842092/how-to-convert-curl-multiple-line-to-one-line https://stackoverflow.com/questions/32341091/multiline-curl-command – kws Jul 14 '17 at 00:27