Skip to main content

aiofcm - An efficient Firebase Cloud Messaging Client Library for Python/asyncio

https://travis-ci.org/Fatal1ty/aiofcm.svg?branch=master https://img.shields.io/pypi/v/aiofcm.svg https://img.shields.io/pypi/pyversions/aiofcm.svg https://img.shields.io/badge/License-Apache%202.0-blue.svg

aiofcm is a library designed specifically for sending messages such as push-notifications to Android devices via Firebase Cloud Messaging platform. aiofcm provides an efficient client through asynchronous XMPP protocol for use with Python’s asyncio framework.

aiofcm requires Python 3.5 or later.

Performance

In my testing aiofcm allows you to send on average 1k messages per second on a single core.

Features

  • Internal connection pool which adapts to the current load

  • Sending notification and/or data messages

  • Ability to set TTL (time to live) for messages

  • Ability to set priority for messages

  • Ability to set collapse-key for messages

Installation

Use pip to install:

$ pip install aiofcm

Basic Usage

from uuid import uuid4
from aiofcm import FCM, Message, PRIORITY_HIGH


async def run():
    fcm = FCM(123456789000, '<API_KEY>')
    message = Message(
        device_token='<DEVICE_TOKEN>',
        notification={           # optional
            "title": "Hello from Firebase",
            "body": "This is notification",
            "sound": "default"
        },
        data={"score": "3x1"},    # optional
        message_id=str(uuid4()),  # optional
        time_to_live=3,           # optional
        priority=PRIORITY_HIGH,   # optional
    )
    await fcm.send_message(message)

loop = asyncio.get_event_loop()
loop.run_until_complete(run())

License

aiofcm is developed and distributed under the Apache 2.0 license.

Release files for aiofcm 1.4

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

Source distribution (sdist)

Source distribution for aiofcm 1.4
File Size Uploaded
aiofcm-1.4.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiofcm 1.4
File Interpreter ABI Platform
aiofcm-1.4-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / aiofcm-1.4.tar.gz

Download URL aiofcm-1.4.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ff0e97c4f3d4db65a459ef44c485a80869f0567992a15b757942cb37b4b050d0
BLAKE2b-256 checksum
How to use checksums
654c515e44a26c5e9c7496ea682ad6ca5400b3db6a23c922cd682b224c33b855
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / aiofcm-1.4-py3-none-any.whl

Download URL aiofcm-1.4-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41ed993a74f19fc9f82df16ca66a9f32d0f3a3d1d851d44d95c67b3078ab6700
BLAKE2b-256 checksum
How to use checksums
262f9bd60b441c9ec08a5e43f285089e06851bbfaf789d7dc4626b43375002d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

1.4 This release

2 release files

1.3.1

2 release files

1.3

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

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