You've already forked RekomenciBackend
feat(): push notifications via firebase admin
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import asyncio
|
||||
from typing import override
|
||||
|
||||
from firebase_admin import messaging # type: ignore[import-untyped]
|
||||
from firebase_admin.messaging import Message, Notification # type: ignore[import-untyped]
|
||||
|
||||
from template_project.application.common.notifications.service import NotificationService
|
||||
|
||||
|
||||
class FCMNotificationService(NotificationService):
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@override
|
||||
async def send_notification(self, identifier: str, title: str, body: str) -> None:
|
||||
message = Message(
|
||||
token=identifier,
|
||||
notification=Notification(title=title, body=body),
|
||||
)
|
||||
await asyncio.to_thread(messaging.send, message)
|
||||
Reference in New Issue
Block a user