Django application to send push notifications to IOS and Android devices using Amazon SNS.
Project description
Django Sloop is the fastest & most reliable RESTful push notification service so far. This package contains some tools that will ease the implementation of sloop into django projects.
Django-Sloop
Installation
-
Install the package via Github or PIP (pip install django-sloop)
-
Add django_sloop to the INSTALLED_APPS list in the settings file.
-
Extend the django_sloop.models.AbstractSNSDevice class and create your own push token device model.
# models.py
from django_sloop.models import AbstractSNSDevice
class Device(AbstractSNSDevice):
pass
# (Optional) if you need to override Meta.
class Meta(AbstractSNSDevice.Meta):
pass
- Make sure that you fill necessary information at the settings file:
# settings.py
DJANGO_SLOOP_SETTINGS = {
"AWS_REGION_NAME": "",
"AWS_ACCESS_KEY_ID": "",
"AWS_SECRET_ACCESS_KEY": "",
"SNS_IOS_APPLICATION_ARN": "test_ios_arn",
"SNS_IOS_SANDBOX_ENABLED": False,
"SNS_ANDROID_APPLICATION_ARN": "test_android_arn",
"DEFAULT_SOUND": "",
"DEVICE_MODEL": "module_name.Device",
}
You cannot change the DEVICE_MODEL setting during the lifetime of a project (i.e. once you have made and migrated models that depend on it) without serious effort. The model it refers to must be available in the first migration of the app that it lives in.
- Create migrations for newly created Device model and migrate.
Note: django_sloop's migrations must run after your Device is created. If you run into a problem while running migrations add following to the your migration file where the Device is created.
run_before = [
('django_sloop', '0001_initial'),
]
- Add django_sloop.models.PushNotificationMixin to your User model.
class User(PushNotificationMixin, ...):
pass
user.send_push_notification_async(message="Sample push notification.")
- Add django_sloop.admin.SloopAdminMixin to your UserAdmin to enable sending push messages to users from Django admin panel.
# admin.py
from django_sloop.admin import SloopAdminMixin
from django.contrib import admin
class UserAdmin(SloopAdminMixin, admin.ModelAdmin):
actions = ("send_push_notification", )
- Add django rest framework urls to create and delete device.
# urls.py
from django.conf.urls import url
from django.urls import include
urlpatterns = [
# ...
url(r'^api/devices/', include('django_sloop.urls')),
# ...
]
Done!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-sloop-1.0.2.tar.gz
.
File metadata
- Download URL: django-sloop-1.0.2.tar.gz
- Upload date:
- Size: 59.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df52e66a4a0c7dd9fa2c4da6a93ecc3d2861c233f5f5f109b1c068588d1cc27b |
|
MD5 | 511036bc2a0dd74a0ae115f3723b5cdd |
|
BLAKE2b-256 | d84fd91284bb437ccbed022c392bf7d0aba424bb08c54b5c01009160766cd714 |