push_messaging.py 782 Bytes
from firebase_admin import messaging
from firebase_admin import credentials
import firebase_admin

cred = credentials.Certificate('wello_firebase_SDKKey.json')
default_app = firebase_admin.initialize_app(cred)

def send_to_topic():
    # [START send_to_topic]
    # The topic name can be optionally prefixed with "/topics/".
    topic = 'c1_1'

    # See documentation on defining a message payload.
    message = messaging.Message(
        title = 'wef',
        data={
            'score': '850',
            'time': '2:45',
        },
        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)

send_to_topic()