Skip to main content

FCM/GCM push notification client

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.5.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

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

firebase_messaging-0.4.5-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: firebase_messaging-0.4.5.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for firebase_messaging-0.4.5.tar.gz
Algorithm Hash digest
SHA256 11f19509ea839e53f995d93d25d63a4a1385572a37fc2cff2c1b389534cb80f1
MD5 b50bf0ffedecc0803ee592a99394d586
BLAKE2b-256 52a020dc16682beff1b382ec10a9fba156f9bd5c33bfbbf227be5af437daff94

See more details on using hashes here.

Provenance

The following attestation bundles were made for firebase_messaging-0.4.5.tar.gz:

Publisher: publish.yml on sdb9696/firebase-messaging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for firebase_messaging-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b566b5dedb15463fa35540d42acfda41040a2ae19c562b33b52f226e90212168
MD5 876b77f31800706c9cbed14caef651f4
BLAKE2b-256 1d10f4e266f9e0aa025d23077c733e5a7f646fc9ced3c8b2711168e93d12742a

See more details on using hashes here.

Provenance

The following attestation bundles were made for firebase_messaging-0.4.5-py3-none-any.whl:

Publisher: publish.yml on sdb9696/firebase-messaging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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