aiofcm
aiofcm copied to clipboard
Can't send noti if use class FCM such as attribute in ViewSet (Django)
Below is my code but it not run send_messages function. Complier not raise any exceptions. Please.....
`class AsyncNotificationViewSet(ViewSet):
FCM_SENDER_ID = <FCM_SENDER_ID >
FCM_API_KEY = <FCM_API_KEY >
fcm = FCM(FCM_SENDER_ID, FCM_API_KEY)
async def send_message(self):
print(self.fcm.pool.connections)
message = Message(
device_token=<device_token>,
notification={
"title": "Hello from Firebase",
"body": "This is notification",
"sound": "default"
}
)
await self.fcm.send_message(message)
print(self.fcm.pool.connections)
async def cron(self, request):
try:
loop = asyncio.get_event_loop()
send_messages = [self.send_message() for _ in range(1)]
res = await asyncio.wait(send_messages)
return success_response()
except Exception as e:
print(e)
return HttpResponse(str(e))`
No one will help you without details