notification: add firebase notification to web

This commit is contained in:
behruz-dev
2025-10-30 14:59:59 +05:00
parent b6b2875e0d
commit 9b4f343f77
10 changed files with 198 additions and 79 deletions

View File

@@ -1,4 +1,8 @@
import requests
from firebase_admin import messaging
from django.conf import settings
def send_notification(token, title, body, data=None):
message = {
@@ -11,6 +15,19 @@ def send_notification(token, title, body, data=None):
response = requests.post(
"https://exp.host/--/api/v2/push/send",
json=message,
headers={"Content-Type": "application/json"}
headers={"Content-Type": "application/json"},
)
return response.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)