{"id":16239134,"url":"https://github.com/xtrinch/fcm-django-web-demo","last_synced_at":"2025-05-10T19:32:31.865Z","repository":{"id":17547366,"uuid":"82215495","full_name":"xtrinch/fcm-django-web-demo","owner":"xtrinch","description":"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.","archived":false,"fork":false,"pushed_at":"2024-08-28T14:32:37.000Z","size":77,"stargazers_count":74,"open_issues_count":4,"forks_count":52,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-10T07:47:39.497Z","etag":null,"topics":["django","firebase-web","notifications","push-notifications","web-push-notification"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xtrinch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-16T19:01:18.000Z","updated_at":"2024-12-20T17:04:45.000Z","dependencies_parsed_at":"2024-05-28T13:34:45.541Z","dependency_job_id":"63ffc30e-e1e4-49b0-9b49-2ba7522a3e5a","html_url":"https://github.com/xtrinch/fcm-django-web-demo","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtrinch%2Ffcm-django-web-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtrinch%2Ffcm-django-web-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtrinch%2Ffcm-django-web-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtrinch%2Ffcm-django-web-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xtrinch","download_url":"https://codeload.github.com/xtrinch/fcm-django-web-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253470562,"owners_count":21913694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","firebase-web","notifications","push-notifications","web-push-notification"],"created_at":"2024-10-10T13:42:25.356Z","updated_at":"2025-05-10T19:32:31.767Z","avatar_url":"https://github.com/xtrinch.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fcm-django-web-demo\n\nQuick 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.\nPython3 compatible only!\n\n## Quick start\n\n### prerequisites\n- install python 3, pip\n- in `fcm-django-web-demo`:\n  - create virtual environment with `python3 -m venv env`\n  - activate virtual environment with `source env/bin/activate` or `.\\env\\Scripts\\activate.ps1` for Windows' Powershell\n  - install necessary Python packages with `pip install -r mysite/requirements.txt`\n\n### frontend\n- in `fcm-django-web-demo/frontend`:\n  - run server with `python -m http.server 8001`\n\n### backend\n- in `fcm-django-web-demo/mysite`:\n  - run database migrations with `python manage.py migrate`\n  - create Django administrator with `python manage.py createsuperuser`\n  - collect static files with `python manage.py collectstatic`\n  - run server with `python manage.py runserver 0.0.0.0:8000`.\n\n### how to use\n- open http://localhost:8001 in your browser of choice\n- request token and allow firebase to send notifications to your browser (device) - if notifications are already allowed, there will only be a token displayed\n- you should now be seeing your instance id token on the aforementioned URL\n- if you go to django admin, http://localhost:8000/admin/fcm_django/fcmdevice/ and login with the superuser you created earlier, you should be seeing a FCMDevice instance for your browser\n- send yourself a test notification with django admin actions OR\n- send yourself notifications from the shell\n    - example (run `python manage.py shell` from `fcm-django-web-demo/mysite`):\n    ```python\n\t   from firebase_admin.messaging import Message, Notification\n\t   from fcm_django.models import FCMDevice\n\t   device = FCMDevice.objects.all().first()\n\t   device.send_message(Message(notification=Notification(title='title', body='message')))\n    ```\n- voila :)\n\n### optional HTTPS support\n- *why would you want to do this?* because service workers will not work on http, unless you are running them on localhost\n- generate certificate and key with `openssl req -nodes -new -x509 -keyout key.pem -out cert.pem` in `fcm-django-web-demo`\n- in `fcm-django-web-demo/frontend`:\n  - update URL protocol to `https` and `localhost` to your server's IP address in [index.html](https://github.com/xtrinch/fcm-django-web-demo/blob/b8d552830de2b5d82e2d3f787e98d160160c0844/frontend/index.html#L194)\n  - run frontend server with `python server.py` \n- in `fcm-django-web-demo/mysite`:\n  - add your server's IP address to allowed hosts in project settings (shell example: `echo \"ALLOWED_HOSTS = ['172.20.1.10']\" \u003e mysite/local_settings.py`)\n  - run backend server with `python manage.py runsslserver --certificate ../cert.pem --key ../key.pem 0.0.0.0:8000`\n- testing this demo in Chrome may require to run it with `--ignore-certificate-errors` flag to avoid SSL certificate fetch errors\n- during the testing allow untrusted connections to the demo servers on browser prompt\n\n### fcm-django DRF API URL docs demo\n\n- available via `coreapi` and `djangorestframework` pypi packages, can be accessed at http://localhost:8000/docs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtrinch%2Ffcm-django-web-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxtrinch%2Ffcm-django-web-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtrinch%2Ffcm-django-web-demo/lists"}