Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ntthuan060102github opened this issue Mar 23, 2023 · 1 comment
Labels

Comments

@ntthuan060102github
Copy link

ntthuan060102github commented Mar 23, 2023

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))`
@Fatal1ty
Copy link
Owner

No one will help you without details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants