Closed Like6po closed 1 year ago
Can't send push-notification to topic
Code for reproduce:
from async_firebase import AsyncFirebaseClient from async_firebase.messages import Message async def main(): client = AsyncFirebaseClient() client.creds_from_service_account_file("file") android_config = client.build_android_config( priority="high", ttl=2419200, collapse_key="push", title="TEST", body="TEST", icon="https://happycorp.com/logo.png", ) message = Message(android=android_config, topic="weather") response = await client.send(message) print(response.success, response.message_id) if __name__ == "__main__": asyncio.run(main())
Error:
return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/tikey/.pyenv/versions/3.11.1/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/Users/tikey/PycharmProjects/firebase-notify-test/main.py", line 20, in main message = Message(android=android_config, topic="weather") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Message.__init__() missing 1 required positional argument: 'token'
To fix need allow None value for async_firebase.messages.Message.token like: token: str = field(default=None)
token: str = field(default=None)
NIce catch. I will fix it shortly.
Fixed in version 3.1.1
Can't send push-notification to topic
Code for reproduce:
Error:
To fix need allow None value for async_firebase.messages.Message.token like:
token: str = field(default=None)