A Django app to send push notifications to users.
Project description
Mad Notifications
Mad Notifications app for django to send notifications to the user
Quick start
-
Add "mad_notifications" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'mad_notifications', ]
-
Include the notifications URLconf in your project urls.py like this:
path('notifications/', include('mad_notifications.api.urls')),
-
Run
python manage.py migrate
to create the notifications models.
Usage
Shorthand method
from mad_notifications.shorthand import newNotification
# create and send
return newNotification(
user, # django user object
title, # string
content, # string
template_slug = None, # slug from mad_notification.NotificationTemplate
data = {}, # dict
actions = {} # dict
)
Notification Class
from mad_notifications.notification import Notification
# create a notification
notification = Notification(
user = user,
title = "New Order",
content = "You have a new order!",
data = {
'order': order_data,
},
actions = {
'click_action': "ORDER_SCREEN"
},
template = email_template, # mad_notification.EmailTemplate Object
)
# send the notification
notification.notify()
Overriding default
MAD_NOTIFICATIONS = {
"FIREBASE_MOBILE_PUSH_NOTIFICATION_CLASS": "mad_notifications.senders.firebase.FirebaseMobilePushNotification",
"EMAIL_NOTIFICATION_CLASS": "mad_notifications.senders.email.EmailNotification",
}
Developer Guide
Setting up a new provider
Create logic in ~/senders/PROVIDER.py
and call via tasks in ~/notify/PROVIDER.py
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
mad_notifications-4.0.2.tar.gz
(13.5 kB
view hashes)