Skip to main content

Сервис по отправке push-уведомлений через Firebase Cloud Messaging

Общее описание

fcm-notifier представляет собой сервис, который отдельно запускается в окружении РИС и с заданной периодичностью забирает накопившиеся сообщения из очереди, которые пачкой (до 500 штук) отправляет на мобильные устройства через FCM backend используя Firebase Admin SDK.

Настройка сервиса

Для работы сервиса необходимо в переменных окружения задать две переменные:

Путь до JSON-файла содержащего приватный ключ для доступа к сервисам Google:

export GOOGLE_APPLICATION_CREDENTIALS=/opt/bars/fcm-notifier/mydiary.json

Путь до директории содержащей файл конфигурации сервиса:

export FCM_NOTIFIER_CONFIG_DIR=/opt/bars/fcm-notifier/

Файл конфигурации fcm_notifier.conf:

[redis]
REDIS_HOST = 127.0.0.1
REDIS_PORT = 6379
REDIS_DB = 12
REDIS_PASSWORD =

[logging]
LEVEL = INFO

Запуск сервиса

$ fcm-notifier worker

Использование очереди сообщений в РИС

Добавление сообщения в очередь:

from fcm_notifier.helpers import get_redis_connection
from fcm_notifier.notification import Notification, NotificationPayload
from fcm_notifier.queue import RedisQueue


queue = RedisQueue(connection=get_redis_connection())

notification = Notification(
    payload=NotificationPayload(
        title='Test message!',
        body='Message body',
    ),
    token='dsufZwUdSFaeIGFt77aMwm:APA91bHQje7R...',
)

queue.enqueue_notification(notification)

Metadata

Release files for fcm-notifier 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for fcm-notifier 0.2.4
File Interpreter ABI Platform
fcm_notifier-0.2.4-py3-none-any.whl Python 3 none any Details

Release files / fcm_notifier-0.2.4-py3-none-any.whl

Download URL fcm_notifier-0.2.4-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fec579f5324419440f68f3d4b1f6a333e4799e9a248fec3fce9eae7192b6af29
BLAKE2b-256 checksum
How to use checksums
4cc376bdf835613d911eb9f90564053ef0022150bb385a61fa2cfff33993c41a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release history Release notifications | RSS feed

This release

0.2.4 This release

1 release file

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page