Firebase Messaging
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.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| firebase_messaging_hawk-0.5.0.tar.gz | 38.0 kB | Without provenance | Details for firebase_messaging_hawk-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| firebase_messaging_hawk-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for firebase_messaging_hawk-0.5.0-py3-none-any.whl |
Total release size: 73.1 kB
Release files / firebase_messaging_hawk-0.5.0.tar.gz
| Download URL | firebase_messaging_hawk-0.5.0.tar.gz |
|---|---|
| Size | 38.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0ae55020a75b5c636c04b6acf11dc1040ad27a74b49b0088b453f7dc975f260
|
|
BLAKE2b-256 checksum How to use checksums |
0046c97a0c03ba11db656dd901a292b5e2b83950d9c502dc13fe270b67839ac8
|
| 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.5.0-py3-none-any.whl
| Download URL | firebase_messaging_hawk-0.5.0-py3-none-any.whl |
|---|---|
| Size | 35.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
894a6d9e31323acb7ab3e32d06c25a35de2c17d43dd508c42a66423db7efb4be
|
|
BLAKE2b-256 checksum How to use checksums |
a9d8e4a410e166b305e4703440038047c422628596c7fee01a2fed922f448182
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Security for firebase-messaging-hawk 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.