A django app that helps you use ZeroPush's push notification API simply in your django backend for an iOS app.
- a simple HTTP POST interface for adding new push devices connected to the current django user session
- easy to use methods for sending push notifications to a user's all devices /or/ a group of specific devices
- a PushDevice model that is connected to django's built-in user model (and also works with django 1.5+ custom user models)
import zeropush
# Get a user. Can also be a custom user model in django 1.5+
the_user = User.objects.filter(username="johndoe")
zeropush.notify_user(the_user, alert="Here's some notification text", sound="default", badge_number=1)
import zeropush
from zeropush.models import PushDevice
# PushDevice is a model in django-zeropush that has a device token (string) and is connected to a django user.
all_devices = PushDevice.objects.all()
zeropush.notify_devices(all_devices, alert="Here's some text to all users")
- Add
zeropush
to yourINSTALLED_APPS
in your project'ssettings.py
- Add
ZEROPUSH_AUTH_TOKEN="YOUR API TOKEN HERE"
to yoursettings.py
- Include
zeropush.urls
to yoururls.py
if you want a HTTP POST API for adding a push device token to a logged in user. See below for how to POST to it. - Run
./manage.py syncdb
to create the PushDevice model's table. - Now you can send push notifications as above!
Once you've added zeropush.urls
to your urls.py
file, a logged in user session can POST to /zeropush/add_device/
with a parameter token
which is the device token string to a new PushDevice
object that associates the current django user with a specific device token.