Files
ibapp-backend/core/apps/notifications/utils/send_notification.py
2025-10-30 14:59:59 +05:00

33 lines
782 B
Python

import requests
from firebase_admin import messaging
from django.conf import settings
def send_notification(token, title, body, data=None):
message = {
"to": token,
"sound": "default",
"title": title,
"body": body,
"data": data or {},
}
response = requests.post(
"https://exp.host/--/api/v2/push/send",
json=message,
headers={"Content-Type": "application/json"},
)
return response.json()
def send_web_notification(token, title, body, data=None):
message = messaging.MulticastMessage(
notification=messaging.Notification(
title=title,
body=body
),
data=data or {},
tokens=token,
)
response = messaging.send_multicast(message)