FCM notification doesn't send when topic is specified in python back-end

Viewed 197

From python, I want to send a notification to all my android users who subscribed to a specific topic.

I enabled the fcm for my android app, and it works fine when I send a notification from the console to android.

Here's my code:

topic = 'new'

# See documentation on defining a message payload.
message = messaging.Message(
    data={
        'title': 'hahaha',
        'body': 'test',
    },
    topic=topic,
)

# Send a message to the devices subscribed to the provided topic.
response = messaging.send(message)
# Response is a message ID string.
print('Successfully sent message:', response)

The problem is if I don't specify the topic in python (my back-end), the message sends, but when I specify the topic, it doesn't send, what could be wrong here? I'm not getting any error messages. The notification just doesn't appear on my device and when I send a message to devices subscribed to this topic from fcm console, it successfully sends.

0 Answers
Related