subscribeToTopic.py 973 Bytes
import firebase_admin
from firebase_admin import credentials
from firebase_admin import messaging

cred = credentials.Certificate("./wello_firebase_SDKKey.json")
wello = firebase_admin.initialize_app(cred)

print("WELLO project name : ", wello.project_id)

# These registration tokens come from the client FCM SDKs.
registration_tokens = [
    "eSNbW5he2RA:APA91bHqe2ir6xeYq-R143J3pmAD1KuYuPqa-_3oHIw93hQKe9nMGZ2Ol3foV9GXciZCP8WHUbfIEb7Ymr-BGSl22Tau_mvOSqVTqNP5V2UU8sbOjZm9TgBxirxy-A0KynHxKCLcMnYF"
    "dJCm74G7qY0:APA91bGydGRjb91_bX6X8Oyx0kqyFHoXzgF0ZZmD_IygEDCqYPHxJ46os8sHytEmHWIpASDzTk-RZESgkZvdcJavKLJWtVY5uxWl2xUEPefyrcJ-kLWnLHcgPbDTCVLoGe_ZivOFuY9Y"
]

# Subscribe the devices corresponding to the registration tokens to the
# topic.
response = messaging.subscribe_to_topic(registration_tokens, "kisung")

# See the TopicManagementResponse reference documentation
# for the contents of response.
print(response.success_count, 'tokens were subscribed successfully')