Django app which stores, manages Firebase Cloud Messaging and Huawei Messaging Service push tokens and interacts with them.
djangoFCM is Django-compatible application which stores FCM and HMS push tokens, their parameters, and automates push notifications routines.
Main feature is for djangoFCM to be a "plug-in" Django application, thus capable to work with "little-to-no" configuring and changes to Django project.
djangoFCM @ v0.4.9 can:
- store push tokens from FCM or HMS
- link push tokens with their users and applications
- store push notifications
- store push notifications extra kwargs (e.g. deeplinks)
- compose recipients via UI based on user-specified conditions
- watch notifications schedule on calendar
- send scheduled push notifications
- store applications as swappable model
TODO
sample-project
is a showcase django project.
You can reference to it for usage cases, examples, testing.
You must never deploy sample_project
in production due to exposed SECRET_KEY
.
In means of automatisation, djangoFCM heavily relies on celery
(via django-celery-beat
), thus it is your task
to provide celery
and celerybeat
processes and message broker (e.g. rabbitMQ
).
django~=3.2.8
might work on lesser versions, not testeddjango-celery-beat~=2.2.1
might work on lesser versions, not testedpyfcm~=1.5.4
might work on lesser versions, not testedpyhcm~=1.0.6.4
might work on lesser versions, not testeddjango-picklefield~=3.0.1
might work on lesser versions, not tested
django_celery_beat
-
make sure to use latest
pip
:python3 -m pip install --upgrade pip
-
install
djangoFCM
:python3 -m pip install djangoFCM
-
download release asset (
.tar.gz
or.whl
) -
make sure to use latest
pip
:python3 -m pip install --upgrade pip
-
install
djangoFCM
from file:python3 -m pip install /path/to/downloaded/asset.tar.gz # or .whl
-
clone project:
git clone \ --depth=1 \ --branch=master \ git@github.com:omelched/djangoFCM.git \ </path/to/downloads>
-
move
/djangoFCM/djangoFCM
solely to folder containing django appsmv </path/to/downloads>/djangoFCM/djangoFCM \ </path/to/django/project/apps>
-
remove leftovers
rm -rf </path/to/downloads>/djangoFCM
Add djangoFCM
to INSTALLED_APPS
in your Django project settings.py
.
If you installed package the third way, </path/to/django/project/apps>
must be added to PYTHONPATH
. If you not sure add code below in your Django project manage.py
before calling main()
:
sys.path.append('</path/to/django/project/apps>')
Provide FCM api key via DJANGOFCM_FCM_API_KEY
in your Django project settings.py
.
Provide HMS credentials via DJANGOFCM_HMS_CLIENT_ID
, DJANGOFCM_HMS_SECRET
, DJANGOFCM_HMS_PROJECT_ID
in your Django project settings.py
.
If your server has its own model to store Applications — specify model identifier
(e.g. your_app.better_application_model
) in DJANGOFCM_APPLICATION_MODEL
in your Django project settings.py
.
Make sure to point celery to djangoFCM.tasks.send_push_notification
task.
Use app.autodiscover_tasks()
in your celeryapp
module or specify in settings:
CELERY_IMPORTS = (
'djangoFCM.tasks',
)
Provide Celery worker to execute tasks, e.g:
venv/bin/celery -A sample_project worker -l INFO
Official documentation may help.
Provide Celery beat to start scheduled tasks, e.g:
venv/bin/celery -A sample_project beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler
Official documentation on custom schedulers.
Execute database migrations:
python sample_project/manage.py migrate
Collect static:
python sample_project/manage.py collectstatic
@omelched (Denis Omelchenko)
djangoFCM version history and changelist available at releases page.
This project is licensed under the GNU APGLv3 License - see the LICENSE file for details.
Inspiration, code snippets, etc.