簡體   English   中英

消息在 Python firebase-admin 中不起作用

[英]Messaging not working in Python firebase-admin

我正在嘗試使用 python 向 firebase 中的主題發送通知。 但是,我遇到了問題。

這是錯誤消息: message = messaging.Message( NameError: name 'messaging' is not defined

這是代碼:

import firebase_admin
from firebase_admin import credentials


cred = credentials.Certificate("path")
firebase_admin.initialize_app(cred)

topic = 'TestTopic'
def sendPush(title, msg):
    message = messaging.Message(
        data = {
            'title': 'TestTitle',
            'body': 'sometest',
        },
        topic=topic
    )

    response = messaging.send(message)


sendPush('hello', 'test')

任何幫助是極大的贊賞。 謝謝

我想,你忘了定義這個:

from firebase_admin import messaging

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM