aiofcm icon indicating copy to clipboard operation
aiofcm copied to clipboard

Can't send noti if use class FCM such as attribute in ViewSet (Django)

Open ntthuan060102github opened this issue 1 year ago • 1 comments

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))`

ntthuan060102github avatar Mar 23 '23 02:03 ntthuan060102github

No one will help you without details

Fatal1ty avatar Mar 23 '23 07:03 Fatal1ty