Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push notification from python to android

I'm running some scripts and looking for an easy way to ping my phone once the script has finished running.

Doing some research on the web, I've seen ways of sending messages using Slack, Push bullet, twilio, email etc.

I am looking for recommendations for an easy way to send a ping/message from python to my phone.

Easy in the sense it dose not require considerable configuring of outside accounts or pay services.

like image 650
F.D Avatar asked Apr 17 '18 13:04

F.D


People also ask

How do I get python to send notifications?

You can send notifications by calling the notify() function from notification. It takes four parameters: title The large header text at the top of a notification. message The longer, smaller text where you put more detailed information.

Can we send push notification from Android?

Navigate to Settings > Mobile Apps. Click the mobile app for which you'd like to send a push notification. For Device Token, enter the token you located above. For Message, enter a message to display in the push notification.


2 Answers

U can try cmd: pip install telegram-send and just send a message to your Telegram bot. Create your telegram bot at BotFather, take a token from there, paste it to

cmd: telegram-send --configure

Usage:

import telegram_send
telegram_send.send(messages=["Hello world"])

I found this much better than any other push notification.

For more info: Link1 Link2

like image 160
Nick PV Avatar answered Oct 11 '22 14:10

Nick PV


I have found a much easier way, but it doesn't works on Linux. Here is a link for more details.

First you have to install notify_run:

pip install notify_run

Then you have to register:

notify-run register

It will give you a QR code (on windows the QR code doesn't works) and a link, which will take you to a website, there press the "Subscribe on this device" (Maybe you will have to refresh the site)

Then use this code:

from notify_run import Notify

notify = Notify()
notify.send('any message you want')
like image 42
david Avatar answered Oct 11 '22 15:10

david