| import firebase_admin | |
| from firebase_admin import credentials | |
| from firebase_admin import messaging | |
| cred = credentials.Certificate('./env/firebase/faceanimate-firebase-adminsdk-lnj8m-8fefd36f2f.json') | |
| default_app = firebase_admin.initialize_app(cred) | |
| class FCM: | |
| def __init__(self): | |
| pass | |
| def push_notification(title, body, image, topic='testTopic'): | |
| notification = messaging.Notification( | |
| title=title, | |
| body=body, | |
| image=image, | |
| ) | |
| message = messaging.Message( | |
| notification=notification, | |
| topic=topic, | |
| ) | |
| response = messaging.send(message) | |
| if response: | |
| return True | |
| return False | |
| def push_message_to_user(data, registration_token): | |
| message = messaging.Message( | |
| data=data, | |
| token=registration_token, | |
| ) | |
| response = messaging.send(message) | |
| if response: | |
| return True | |
| return False | |
| def __del__(self): | |
| pass |