A simple Django package to integrate Web Push Notification in your Application
Project description
Django-Webpush
==============
Django-Webpush is a Package made for integrating and sending `Web Push
Notification`_ in Django Application. **This is a Work in Progress
package. As the `Web Push Notification specification`_ is still in
draft, things may change soon. So keep updated.**
Currently, it Supports Sending Push Notification to **Firefox 46+ and
Chrome 52+**.
--------------
Installation and Setup
----------------------
You can install it easily from pypi by running
::
pip install django-webpush
After installing the package, add ``webpush`` in in your
``INSTALLED_APPS`` settings
.. code:: python
INSTALLED_APPS = (
...
'webpush',
)
If you would like to send notification to Google Chrome Users, you need
to add a ``WEBPUSH_SETTINGS`` entry with the **Vapid Credentials** Like
following:
.. code:: python
WEBPUSH_SETTINGS = {
"VAPID_PUBLIC_KEY": "Vapid Public Key",
"VAPID_PRIVATE_KEY":"Vapid Private Key",
"VAPID_ADMIN_EMAIL": "admin@example.com"
}
**Replace ``"Vapid Public Key"`` and ``"Vapid Private Key"`` with your
Vapid Keys. Also replace ``admin@example.com`` with your email so that
the push server of browser can reach to you if anything goes wrong.**
**To know how to obtain Vapid Keys please see this ```py_vapid```_
and `Google Developer Documentation`_. You can obtain one easily
from `web-push-codelab.glitch.me`_. ``Application Server Keys`` and
``Vapid Keys`` both are same.**
Then include ``webpush`` in the ``urls.py``
::
urlpatterns =
url(r'^webpush/', include('webpush.urls'))
]
Then run Migration by **``python manage.py migrate``**
Adding Web Push Information in Template
---------------------------------------
So in template, you need to load ``webpush_notifications`` custom
template tag by following: > - If you are using built in templating
engine, add ``{% load webpush_notifications %}`` in the template > - If
you are using jinja or other templating engine, you can manually add the
html header and button and other information. Documentation for them is
coming soon. Working on getting a automated way for jinja users. If you
would like to add support for them, patch are very much welcome.
Next, inside the ``<head></head>`` tag add ``{% webpush %}``. Like
following
::
<head>
{% webpush %}
</head>
Next, inside the ``<body></body>`` tag, insert ``{% webush_button %}``
where you would like to see the **Subscribe to Push Messaging** Button.
Like following
::
<body>
<p> Hello World! </p>
{% webpush_button %}
</body>
..
**Note:** The Push Notification Button will show only if the user is
logged in or any ``group`` named is passed through ``webpush``
context
\***If you would like to mark the subscription as a gr
.. _Web Push Notification: https://developer.mozilla.org/en/docs/Web/API/Push_API
.. _Web Push Notification specification: https://www.w3.org/TR/push-api/
.. _``py_vapid``: https://github.com/web-push-libs/vapid/tree/master/python
.. _Google Developer Documentation: https://developers.google.com/web/fundamentals/push-notifications/subscribing-a-user#how_to_create_application_server_keys
.. _web-push-codelab.glitch.me: https://web-push-codelab.glitch.me/
==============
Django-Webpush is a Package made for integrating and sending `Web Push
Notification`_ in Django Application. **This is a Work in Progress
package. As the `Web Push Notification specification`_ is still in
draft, things may change soon. So keep updated.**
Currently, it Supports Sending Push Notification to **Firefox 46+ and
Chrome 52+**.
--------------
Installation and Setup
----------------------
You can install it easily from pypi by running
::
pip install django-webpush
After installing the package, add ``webpush`` in in your
``INSTALLED_APPS`` settings
.. code:: python
INSTALLED_APPS = (
...
'webpush',
)
If you would like to send notification to Google Chrome Users, you need
to add a ``WEBPUSH_SETTINGS`` entry with the **Vapid Credentials** Like
following:
.. code:: python
WEBPUSH_SETTINGS = {
"VAPID_PUBLIC_KEY": "Vapid Public Key",
"VAPID_PRIVATE_KEY":"Vapid Private Key",
"VAPID_ADMIN_EMAIL": "admin@example.com"
}
**Replace ``"Vapid Public Key"`` and ``"Vapid Private Key"`` with your
Vapid Keys. Also replace ``admin@example.com`` with your email so that
the push server of browser can reach to you if anything goes wrong.**
**To know how to obtain Vapid Keys please see this ```py_vapid```_
and `Google Developer Documentation`_. You can obtain one easily
from `web-push-codelab.glitch.me`_. ``Application Server Keys`` and
``Vapid Keys`` both are same.**
Then include ``webpush`` in the ``urls.py``
::
urlpatterns =
url(r'^webpush/', include('webpush.urls'))
]
Then run Migration by **``python manage.py migrate``**
Adding Web Push Information in Template
---------------------------------------
So in template, you need to load ``webpush_notifications`` custom
template tag by following: > - If you are using built in templating
engine, add ``{% load webpush_notifications %}`` in the template > - If
you are using jinja or other templating engine, you can manually add the
html header and button and other information. Documentation for them is
coming soon. Working on getting a automated way for jinja users. If you
would like to add support for them, patch are very much welcome.
Next, inside the ``<head></head>`` tag add ``{% webpush %}``. Like
following
::
<head>
{% webpush %}
</head>
Next, inside the ``<body></body>`` tag, insert ``{% webush_button %}``
where you would like to see the **Subscribe to Push Messaging** Button.
Like following
::
<body>
<p> Hello World! </p>
{% webpush_button %}
</body>
..
**Note:** The Push Notification Button will show only if the user is
logged in or any ``group`` named is passed through ``webpush``
context
\***If you would like to mark the subscription as a gr
.. _Web Push Notification: https://developer.mozilla.org/en/docs/Web/API/Push_API
.. _Web Push Notification specification: https://www.w3.org/TR/push-api/
.. _``py_vapid``: https://github.com/web-push-libs/vapid/tree/master/python
.. _Google Developer Documentation: https://developers.google.com/web/fundamentals/push-notifications/subscribing-a-user#how_to_create_application_server_keys
.. _web-push-codelab.glitch.me: https://web-push-codelab.glitch.me/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-webpush-0.2.2.1.tar.gz
(22.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-webpush-0.2.2.1.tar.gz.
File metadata
- Download URL: django-webpush-0.2.2.1.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de9aa2da316d42501a6ee55941d07f6209fbff9322847ba8160bf126917caaeb
|
|
| MD5 |
fef2678442a0d987cdcfef1f1d7992f0
|
|
| BLAKE2b-256 |
16afaaf455a85a885b31aff53c11f719f5970efd6397719c3ae5cf26cc7c3e35
|
File details
Details for the file django_webpush-0.2.2.1-py2.py3-none-any.whl.
File metadata
- Download URL: django_webpush-0.2.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89ed51ec49dfe93917063104ed8db9d9db0e88bee1eb1a3fcef0d1a122bcfc1e
|
|
| MD5 |
86345ab805cedc934f6e93fbe64ddffd
|
|
| BLAKE2b-256 |
cdb40414e496d84bf7b7fecca921ebdc165c772ee539d364d8c77a3d58bf4899
|