Skip to content

Instantly share code, notes, and snippets.

@gregtap
Created January 18, 2019 15:23
Show Gist options
  • Select an option

  • Save gregtap/d0e5b27fb836bbb697acf9bdf00334af to your computer and use it in GitHub Desktop.

Select an option

Save gregtap/d0e5b27fb836bbb697acf9bdf00334af to your computer and use it in GitHub Desktop.

Revisions

  1. Greg TAPPERO renamed this gist Jan 18, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. Greg TAPPERO created this gist Jan 18, 2019.
    24 changes: 24 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    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)