Skip to main content

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

Project description

Сервис по отправке 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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fcm_notifier-0.2.4-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file fcm_notifier-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: fcm_notifier-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for fcm_notifier-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fec579f5324419440f68f3d4b1f6a333e4799e9a248fec3fce9eae7192b6af29
MD5 fb21dfb730b99c6499595690778d0286
BLAKE2b-256 4cc376bdf835613d911eb9f90564053ef0022150bb385a61fa2cfff33993c41a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page