send_message: Exactly one of token, topic or condition must be specified.
Closed this issue · 2 comments
Calling send_message on an FCMDeviceQuerySet is returning the following error:
Exactly one of token, topic or condition must be specified.
There is no token, topic or condition directly specified in the message being sent. I'm relying on fcm-django adding the token from the registration_id column (none of them are null or undefined). device_id is NULL in my database, though this seems to be optional.
Using fcm-django 2.2.1 and firebase-admin 6.5.0
Could you please paste a snippet of how you send the message?
The issue was not with fcm-django, but with the firebase-admin library. When attempting to print the Message object before calling send_message, the __str__()
method triggered a validation error. This is because the Message object requires exactly one of token, topic, or condition to be set before serialization, which is enforced in the MessageEncoder.
For reference, you can see the relevant code here.