So, you want to notify the user via email or push notification or sms or whatsapp or whatever, after they did something on your website/app.
Installation
Install mad_notifications
from using pip install mad_notifications
INSTALLED_APPS = [
...
'mad_notifications',
]
update your project’s urls.py
and add
path('notifications/', include('mad_notifications.api.urls')),
Its installed now, what next?
Basic Usage
Call it where you want it.
from mad_notifications.shorthand import newNotification
return newNotification(
user = get_user_model(id=SOME_ID), # django user object
title = "Welcome to my website/app", # string
content = "Thanks for join my website/app", # string
)
this will send an email to the user, where the title
will be the subject and content
will be the content.
Push Notification
So you want to send them a push notification now? Okay I got you.
Important: Make sure you have firebase already setup in your project.
From your mobile app, generate firebase device token, and post it to /notifications/devices/
this will automatically associate the device token with the user, based on the authorization headers.
Now when you send the notification, it will also send the push notification to that device.