Quick demo to demonstrate the use of firebase web push notifications with the use of `javascript` on frontend, `django` on backend and push notifications via `fcm-django` pypi package for django.
Quick demo to demonstrate the use of firebase web push notifications with the use of javascript
on frontend, django
on backend and push notifications via fcm-django
pypi package for django.
Python3 compatible only!
fcm-django-web-demo
:
python3 -m venv env
source env/bin/activate
or .\env\Scripts\activate.ps1
for Windows' Powershellpip install -r mysite/requirements.txt
fcm-django-web-demo/frontend
:
python -m http.server 8001
fcm-django-web-demo/mysite
:
python manage.py migrate
python manage.py createsuperuser
python manage.py collectstatic
python manage.py runserver 0.0.0.0:8000
.python manage.py shell
from fcm-django-web-demo/mysite
): from firebase_admin.messaging import Message, Notification
from fcm_django.models import FCMDevice
device = FCMDevice.objects.all().first()
device.send_message(Message(notification=Notification(title='title', body='message')))
openssl req -nodes -new -x509 -keyout key.pem -out cert.pem
in fcm-django-web-demo
fcm-django-web-demo/frontend
:
https
and localhost
to your server's IP address in index.html
python server.py
fcm-django-web-demo/mysite
:
echo "ALLOWED_HOSTS = ['172.20.1.10']" > mysite/local_settings.py
)python manage.py runsslserver --certificate ../cert.pem --key ../key.pem 0.0.0.0:8000
--ignore-certificate-errors
flag to avoid SSL certificate fetch errorscoreapi
and djangorestframework
pypi packages, can be accessed at http://localhost:8000/docs