【发布时间】:2020-02-27 05:24:07
【问题描述】:
我正在尝试使用 python 和 firebase 通过令牌向 android 设备发送消息,但是当我运行代码时,我在 response = messaging.send(message) 行出现错误
THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
my_file = os.path.join(THIS_FOLDER, 'wp-crawler-6265d-firebase-adminsdk-kyj8v-d7ccfaa311.json')
cred = credentials.Certificate(my_file)
firebase_admin.initialize_app(cred, {
'databaseURL': 'https://wp-crawler-6265d.firebaseio.com/'
})
for i in range(10):
registration_token = "my key"
message = messaging.Message(
android=messaging.AndroidConfig(
ttl=datetime.timedelta(seconds=3600),
priority='normal',
notification=messaging.AndroidNotification(
title='$GOOG up 1.43% on the day',
body='$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
),
),
token=registration_token,
)
response = messaging.send(message)
print('Successfully sent message:', response)
end = time. time()
print("TIME: ", end-start)
【问题讨论】:
-
错误提示未找到请求的实体
标签: python firebase firebase-realtime-database firebase-cloud-messaging firebase-admin