1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 from firebase_admin import credentials, messaging
7 from django.conf import settings
11 if hasattr(settings, 'FCM_PRIVATE_KEY_PATH'):
12 cred = credentials.Certificate(settings.FCM_PRIVATE_KEY_PATH)
13 firebase_admin.initialize_app(cred)
15 TOPIC = 'wolnelektury'
18 def send_fcm_push(title, body, image_url=None):
21 # See documentation on defining a message payload.
28 data['imageUrl'] = image_url
29 message = messaging.Message(
30 notification=messaging.Notification(
37 message_id = messaging.send(message)