X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e17ba704033aba068a935c1beb42d1f306e6a114..9ce7b544a0616db407be602ea453771fc9c0a6dd:/src/push/utils.py?ds=sidebyside diff --git a/src/push/utils.py b/src/push/utils.py index 98f035919..684531588 100644 --- a/src/push/utils.py +++ b/src/push/utils.py @@ -6,15 +6,24 @@ import firebase_admin from firebase_admin import credentials, messaging from django.conf import settings -cred = credentials.Certificate(settings.FCM_PRIVATE_KEY_PATH) -firebase_admin.initialize_app(cred) + +cred = None +if hasattr(settings, 'FCM_PRIVATE_KEY_PATH'): + cred = credentials.Certificate(settings.FCM_PRIVATE_KEY_PATH) + firebase_admin.initialize_app(cred) TOPIC = 'wolnelektury' def send_fcm_push(title, body, image_url=None): + if cred is None: + return # See documentation on defining a message payload. data = {} + # data = { + # 'title': title, + # 'body': body, + # } if image_url: data['imageUrl'] = image_url message = messaging.Message(