Skip to content

Instantly share code, notes, and snippets.

@jvfiel
Created August 7, 2017 08:12
Show Gist options
  • Save jvfiel/75f34988340996f072da74272b8ef368 to your computer and use it in GitHub Desktop.
Save jvfiel/75f34988340996f072da74272b8ef368 to your computer and use it in GitHub Desktop.
def send_notification():
# Send to single device.
from pyfcm import FCMNotification
push_service = FCMNotification(api_key="AIzaSyCgw3CjkdzXxGdhvEW8IYh-dIf5jYvPJQs")
# OR initialize with proxies
# proxy_dict = {
# "http": "http://127.0.0.1",
# "https": "http://127.0.0.1",
# }
# push_service = FCMNotification(api_key="<api-key>", proxy_dict=proxy_dict)
# Your api-key can be gotten from: https://console.firebase.google.com/project/<project-name>/settings/cloudmessaging
registration_id = "diIOhYflVGs:APA91bF05YDka57b9cyyQJx-9_HaGvorgsS4vEhJyjDmKQIYxqn66sITSAikQ9fF6jXlm6mMgLsiphcB1HwaVUR-ZPAGVgTMG6rV7ohTxQmE3txhNcgJ1-sy9VdoZg2YwSmP0ycJohZX"
message_title = "Master Jun"
message_body = "Hi Jun"
result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title,
message_body=message_body)
# Send to multiple devices by passing a list of ids.
# registration_ids = ["<device registration_id 1>", "<device registration_id 2>", ...]
# message_title = "Uber update"
# message_body = "Hope you're having fun this weekend, don't forget to check today's news"
# result = push_service.notify_multiple_devices(registration_ids=registration_ids, message_title=message_title,
# message_body=message_body)
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment