Skip to main content

FCM/GCM push notification client

Reason this release was yanked:

Yanked due to compatability issues with protobuf compilations

Project description

PyPI Version Build Status Coverage Documentation Status Py Versions

A library to subscribe to GCM/FCM and receive notifications within a python application.

When should I use firebase-messaging ?

  • I want to receive push notifications sent using Firebase Cloud Messaging in a python application.

When should I not use firebase-messaging ?

  • I want to send push notifications (use the firebase SDK instead)

  • My application is running on a FCM supported platform (Android, iOS, Web).

Install

PyPi:

$ pip install firebase-messaging

Requirements

  • Firebase configuration to receive notifications

Usage

Must be run inside an asyncio event loop.

python:

from firebase_messaging import FcmPushClient, FcmRegisterConfig

def on_notification(obj, notification, data_message):
    # Do something with the notification
    pass

credentials = None  # Start off with none or load from previous save
def on_credentials_updated(creds):
    # save the credentials to a file here for future use

fcm_config = FcmRegisterConfig(fcm-project-id, fcm-app-id, fcm-api-key, fcm-message-sender-id)
pc = FcmPushClient(on_notification, fcm_config, credentials, on_credentials_updated)
fcm_token = await pc.checkin_or_register()

await pc.start()

# Adapt the following for your usage
while some_condition_to_keep_listening:
    asyncio.sleep(2)

Attribution

Code originally based on typescript/node implementation by Matthieu Lemoine. See this blog post for more details.

Converted to python by lolisamurai

http decryption logic in decrypt.py by Martin Thomson

Project details


Download files

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

Source Distribution

firebase_messaging-0.4.3.tar.gz (36.3 kB view details)

Uploaded Source

Built Distribution

firebase_messaging-0.4.3-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file firebase_messaging-0.4.3.tar.gz.

File metadata

  • Download URL: firebase_messaging-0.4.3.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for firebase_messaging-0.4.3.tar.gz
Algorithm Hash digest
SHA256 a8a236a6b07edbb75de7633b9eb4e16a99ee7ab342f61f045613d3f3ef7f2687
MD5 beb30c169e069cc780ce5d5103d638bd
BLAKE2b-256 18b0bd99246a8562c104fe80bf66a53a130662c6d5f075cfba6ca3c799fd05fd

See more details on using hashes here.

File details

Details for the file firebase_messaging-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for firebase_messaging-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1cb795d8429819db622b5e33ddedb3eae8f53a96ed8780fab918540f2fdedb2e
MD5 b161a9c385822588fa6aefcb97f06163
BLAKE2b-256 008c1066f1a2a60b43b078043bcef2e6002fe9b683257a526bf197b088af59a9

See more details on using hashes here.

Supported by

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