Python-Firebase云消息传递

时间:2019-07-02 16:29:51

标签: android python firebase firebase-cloud-messaging

我想从python发送一条通知给所有订阅特定主题的android用户。

这是我得到的错误:

firebase_admin.messaging.ApiCallError: Firebase Cloud Messaging API has not been used in project 432453324 before or it is disabled. Enable it by visiting https://console.developers.goo
gle.com/apis/api/fcm.googleapis.com/overview?project=432453324 then retry. 

我为我的android应用启用了fcm,当我从控制台向android发送通知时,它运行良好,但是使用python时出了点问题,这是什么?

这是我的代码:

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)

0 个答案:

没有答案