All Projects → rakanalh → Django Pushy

rakanalh / Django Pushy

Licence: mit
Your push notifications handled at scale.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Django Pushy

Django Celery Tutorial
Django Celery Tutorial
Stars: ✭ 48 (-71.43%)
Mutual labels:  django, celery
Django Guid
Inject an ID into every log message from a Django request. ASGI compatible, integrates with Sentry, and works with Celery
Stars: ✭ 166 (-1.19%)
Mutual labels:  django, celery
Bugsnag Python
Official bugsnag error monitoring and error reporting for django, flask, tornado and other python apps.
Stars: ✭ 69 (-58.93%)
Mutual labels:  django, celery
Ops
基于centos6+python3.6+django2+ansible2.4+celery4.2 运维管理系统,目前实现功能:用户和用户组管理、资产管理、集成ansible2.4、简易堡垒机(主机分配支持rdp以及vnc、用户分配、文件上传下载、配置禁用命令清单、操作录像回放功能)、CI/CD(支持git仓库和svn仓库)、数据库管理(一部分)、celery任务编排、知识库及文件共享
Stars: ✭ 502 (+198.81%)
Mutual labels:  django, celery
Dailyfresh
Django-天天生鲜电商学习项目
Stars: ✭ 127 (-24.4%)
Mutual labels:  django, celery
Django Celery Beat
Celery Periodic Tasks backed by the Django ORM
Stars: ✭ 884 (+426.19%)
Mutual labels:  django, celery
Playlistor
🎶Apple Music ↔️ Spotify playlist convertor.
Stars: ✭ 95 (-43.45%)
Mutual labels:  django, celery
Autoops
linux资产管理,cmdb,django, webssh,运维管理平台,数据库操作平台 本项目已停止开发!因长时间未对代码进行维护,可能会造成项目在不同环境上无法部署、运行BUG等问题,请知晓!项目仅供参考!
Stars: ✭ 340 (+102.38%)
Mutual labels:  django, celery
Django Structlog
Structured Logging for Django
Stars: ✭ 127 (-24.4%)
Mutual labels:  django, celery
Django Celery
Old Celery integration project for Django
Stars: ✭ 1,439 (+756.55%)
Mutual labels:  django, celery
Fcm Django
FCM Django: Send push notifications via django to websites, iOS & android mobile devices through FCM (Firebase Cloud Messaging)
Stars: ✭ 495 (+194.64%)
Mutual labels:  django, push-notifications
Django Celery Docker Example
Example Docker setup for a Django app behind an Nginx proxy with Celery workers
Stars: ✭ 149 (-11.31%)
Mutual labels:  django, celery
Docker Django
A complete docker package for deploying django which is easy to understand and deploy anywhere.
Stars: ✭ 378 (+125%)
Mutual labels:  django, celery
Framework
The Framework is a set of components and tools which brings the user an interface (GUI / API) to setup, extend and manage an Open vStorage platform.
Stars: ✭ 27 (-83.93%)
Mutual labels:  django, celery
Django Celery Email
A Django email backend that uses a celery task for sending the email.
Stars: ✭ 351 (+108.93%)
Mutual labels:  django, celery
Docker Django Example
A production ready example Django app that's using Docker and Docker Compose.
Stars: ✭ 86 (-48.81%)
Mutual labels:  django, celery
Letsmapyournetwork
Lets Map Your Network enables you to visualise your physical network in form of graph with zero manual error
Stars: ✭ 305 (+81.55%)
Mutual labels:  django, celery
Django Celery Results
Celery result back end with django
Stars: ✭ 337 (+100.6%)
Mutual labels:  django, celery
Banking System
A banking System Created Using Django Python Web Framework
Stars: ✭ 105 (-37.5%)
Mutual labels:  django, celery
Django Push Notifications
Send push notifications to mobile devices through GCM or APNS in Django.
Stars: ✭ 1,881 (+1019.64%)
Mutual labels:  django, push-notifications

django-pushy

Your push notifications handled at scale.

.. image:: https://travis-ci.org/rakanalh/django-pushy.svg?branch=master :target: https://travis-ci.org/rakanalh/django-pushy .. image:: https://coveralls.io/repos/rakanalh/django-pushy/badge.png?branch=master :target: https://coveralls.io/r/rakanalh/django-pushy?branch=master .. image:: https://landscape.io/github/rakanalh/django-pushy/master/landscape.svg?style=flat :target: https://landscape.io/github/rakanalh/django-pushy/master :alt: Code Health

What does it do?

Python / Django app that provides push notifications functionality with celery. The main purpose of this app is to help you send push notifications to your users at scale. If you have lots of registered device keys, django-pushy will split your keys into smaller groups which run in parallel making the process of sending notifications faster.

Setup

You can install the library directly from pypi using pip::

$ pip install django-pushy

Add django-pushy to your INSTALLED_APPS::

INSTALLED_APPS = (
    ...
    "djcelery",
    "pushy"
)

Configurations::

# Android
PUSHY_GCM_API_KEY = 'YOUR_API_KEY_HERE'

# Send JSON or plaintext payload to GCM server (default is JSON)
PUSHY_GCM_JSON_PAYLOAD = True

# iOS
PUSHY_APNS_SANDBOX = True or False
PUSHY_APNS_CERTIFICATE_FILE = 'PATH_TO_CERTIFICATE_FILE'

PUSHY_QUEUE_DEFAULT_NAME = 'default'
PUSHY_DEVICE_KEY_LIMIT = 1000

Run DB migrations::

python manage.py migrate

How do i use it?

There are 2 models provided by Pushy:

  1. PushNotification
  2. Device

You have to implement your own code to use the Device model to register keys into the database::

from pushy.models import Device
Device.objects.create(key='123', type=Device.DEVICE_TYPE_ANDROID, user=current_user)
Device.objects.create(key='123', type=Device.DEVICE_TYPE_IOS, user=None)

Whenever you need to push a notification, use the following code::

from pushy.utils import send_push_notification
send_push_notification('Push_Notification_Title', {'key': 'value' ...})

This will send a push notification to all registered devices. You can also send a single notification to a single device::

device = Device.objects.get(pk=1)
send_push_notification('YOUR TITLE', {YOUR_PAYLOAD}, device=device)

Or you can use the filter_user or filter_type to make pushy send to a specified queryset of devices::

send_push_notification('YOUR TITLE', {YOUR_PAYLOAD}, filter_user=user)
send_push_notification('YOUR TITLE', {YOUR_PAYLOAD}, filter_type=Device.DEVICE_TYPE_IOS)

If you don't want to store the push notification into the database, you could pass in a keyword argument::

send_push_notification('YOUR_TITLE', {YOUR_PAYLOAD}, device=device, store=False)

If you would like to add a push notification without triggering any action right away, you should be setting the property "payload instead of adding your dict to body as follows::

notification = PushNotification.objects.create(
    title=title,
    payload=payload,
    active=PushNotification.PUSH_ACTIVE,
    sent=PushNotification.PUSH_NOT_SENT
)

As some serialization takes place to automatically convert the payload to a JSON string to be stored into the database.

iOS Users Note: Please note that iOS special parameters: alert, sound, badge, content-available are all preset for you to None/False. Django-pushy ads payload you provide to the custom payload field.

Restful APIs

To use Restful APIs, pushy requires DRF >= 3.0.::

pip install django-pushy[apis]

And add the following to your urls.py::

from pushy.contrib.rest_api import urls as pushy_rest_urls

urlpatterns += [
    url(r'^api/', include(rest_urls))
]

At this point you'll be able to make POST & DELETE requests to /api/pushy/device. An example request (using httpie tool) to create a key is::

http http://<URL>/api/pushy/device/ key=<key-here> type=ios --json

To delete a key::

http delete http://<URL>/api/pushy/device/ key=<key-here> --json

Admin

Django-pushy also provides an admin interface to it's models so that you can add a push notification from admin.

For that to work, you need to add "check_pending_push_notifications" task into your periodic tasks in celery admin. Make sure you setup::

djcelery.setup_loader()
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'

And don't forget to run celerybeat.

Running the tests

Install mock::

pip install mock

then run the following from the project's root::

py.test .

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].