Skip to main content

Firebase Messaging

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

Metadata

Release files for firebase-messaging-hawk 0.4.7

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

Source distribution (sdist)

Source distribution for firebase-messaging-hawk 0.4.7
File Size Uploaded
firebase_messaging_hawk-0.4.7.tar.gz 37.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for firebase-messaging-hawk 0.4.7
File Interpreter ABI Platform
firebase_messaging_hawk-0.4.7-py3-none-any.whl Python 3 none any Details

Total release size: 72.8 kB

Release files / firebase_messaging_hawk-0.4.7.tar.gz

Download URL firebase_messaging_hawk-0.4.7.tar.gz
Size 37.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fc479d8f9443ca714c3f2652238f0f0171a483a35c5c594ff153ef95d6c70f67
BLAKE2b-256 checksum
How to use checksums
3c7826ce25ea8e8cead1ef10224eb8908d8f423340551b6be0810a6631bfc1f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / firebase_messaging_hawk-0.4.7-py3-none-any.whl

Download URL firebase_messaging_hawk-0.4.7-py3-none-any.whl
Size 34.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a147b1390be3235b47162584300685e3d936beed210193ffe01bed1b9bc66d8d
BLAKE2b-256 checksum
How to use checksums
78d61b82be85b78519eb6b422ea2986e43170f3ed84e90512137e20582612973
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.9

2 release files

0.4.8

2 release files

This release

0.4.7 This release

2 release files

0.4.6

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