In this tutorial, you will learn, how to send Push Notification using the Python programming(Automated).

https://ampersandacademy.com/tutorials/ionic-framework-version-2/push-notification-automate-using-php

The above link explains
1. How to create a basic Ionic 2 project
2. How to install the necessary push plugins
3. How to get the Firebase Cloud Messaging Server API Key
4. How to get the Device registration id.
5. How to generate APK

You have to create a simple working push notification Ionic 2 application using the above link. 

When you open the application on your device, it will generate a device registration id for push notification, which can be stored in the database. However, the above example had PHP code to catch and save the device registration id. So you have to write your PHP server code to catch data or you can use python web frameworks to catch data.

To execute the Firebase Cloud Messaging URL in Python, you need the requests package.

Install the requests package using the below command in terminal.

pip install requests

Python Code for Push Notification

import requests
import json

API_ACCESS_KEY='YOUR_API_ACCESS_KEY'

registrationIds=['DEVICE_REGISTRATION_ID']

url = 'https://android.googleapis.com/gcm/send'

msg={'message':'here is a message. message',
'title':'This is a title. title',
'subtitle':'This is a subtitle. subtitle',
'tickerText':'Ticker text here...Ticker text here...Ticker text here',
'vibrate':1,
'sound':1,
'largeIcon':'large_icon',
'smallIcon':'small_icon'
}
fields = {
'registration_ids': registrationIds,
'data': msg
}

# Adding empty header as parameters are being sent in payload
headers = {'Authorization':'key='+API_ACCESS_KEY,
'Content-Type': 'application/json'}
r = requests.post(url, data=json.dumps(fields), headers=headers)
print(r.content)

Replace the YOUR_API_ACCESS_KEY with your Firebase Cloud Messaging API key. And also replace the DEVICE_REGISTRATION_ID with the actually generated device registration id. Then save the above code as push.py and run the above code using

python push.py

That's all.