Created
March 20, 2019 11:14
-
-
Save imaginabit/8135278e5ebbdd278da28ca0e1781e23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install pyfcm | |
from pyfcm import FCMNotification | |
push_service = FCMNotification(api_key="< FIREBASE API KEY YOU FOUND IN PROYECT settings cloudmessaging/ >") | |
# 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 = "< USER FIREBASE TOKEN >" | |
message_title = "Notificacion test" | |
message_body = "Hi john, your customized news for today is ready" | |
options = { | |
"data": | |
{ | |
"resource": "message", | |
"message_id": 467, | |
"conversation": 151, | |
"author_id": 247 | |
} | |
} | |
data = { | |
"resource": "message", | |
"message_id": 467, | |
"conversation": 151, | |
"author_id": 247 | |
} | |
# result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title, message_body=message_body) | |
result = push_service.notify_single_device(registration_id=registration_id, message_title=message_title', data_message=data ) | |
print( result ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment