Skip to content

Instantly share code, notes, and snippets.

@gregtap
Created January 18, 2019 15:23
Show Gist options
  • Save gregtap/d0e5b27fb836bbb697acf9bdf00334af to your computer and use it in GitHub Desktop.
Save gregtap/d0e5b27fb836bbb697acf9bdf00334af to your computer and use it in GitHub Desktop.
import firebase_admin
from firebase_admin import credentials, messaging
cred = credentials.Certificate("/Users/greg/Downloads/chefclub-notifications-test-1-firebase-adminsdk-0qqbs-7cb7b7b6c4.json")
firebase_admin.initialize_app(cred)
# This registration token comes from the client FCM SDKs.
registration_token = 'cjNg-fBsWsE:APA91bEc-pDmnfkyczdJroTv-KNHpucA7WhYrmxWrgcSz4HHqn5vhodglqI3mqUSZnz0_VhuJjCrvGUVyqbRR-YnP8DuxdeHQyp1BUiF-H2V2ockNJ2OO-yEh6Im2EFhI6KHUd3ettEg'
# See documentation on defining a message payload.
message = messaging.Message(
data={
'score': '850',
'time': '2:45',
},
token=registration_token,
)
# Send a message to the device corresponding to the provided
# registration token.
response = messaging.send(message)
# Response is a message ID string.
print('Successfully sent message:', response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment