FCM Adapter
This is a simple adapter for the FCM (Firebase Cloud Messaging) service.
Installation
pip install fcm_adapter
poetry add fcm_adapter
Usage
from fcm_adapter import FCMAdapter
import json
async def main(token: str):
with open('key.json') as f:
key = json.load(f)
fcm_adapter = FCMAdapter(key)
await fcm_adapter.send_message(
{
"token": token,
"notification": {"title": "Hello World"},
}
)
FCMAdapter initialization
Parameters
key: dict- Google key. You can get it from the Firebase Console. Documentation here.client: Union[httpx.AsyncClient, None] = None- httpx.AsyncClient instance. If not provided, a new instance will be created.send_message_url: Union[str, None] = None- FCM send message url. If not provided, the default value will be used.validate_only: bool = False- Flag for testing the request without actually delivering the message. Works only with thesend_messagemethod.
send
Send a message to a device. See FCM documentation for more details.
Parameters
data: dict- Data to send to FCM service.
Returns
- Response from FCM service. See FCM documentation for more details.
Example
from fcm_adapter import FCMAdapter
async def main(fcm_adapter: FCMAdapter, token: str):
response = await fcm_adapter.send(
{
"validate_only": False,
"message": {
"token": token,
"notification": {"title": "Hello World"},
},
}
)
send_message
Send a message to a device. The function is a wrapper around the send method,
but it expects to receive only inner message data.
If fcm_adapter.validate_only is set to True,
the request to FCM will be sent with "validate_only": true.
Parameters
message: dict- Message data to send to FCM service.
Returns
- Response from FCM service. See FCM documentation for more details.
Example
from fcm_adapter import FCMAdapter
async def main(fcm_adapter: FCMAdapter, token: str):
response = await fcm_adapter.send_message(
{
"token": token,
"notification": {"title": "Hello World"},
}
)
Development
First, install poetry.
Then, install dependencies:
poetry install
Formatting
poetry run black .
Testing
poetry run pytest
Metadata
Release files for fcm-adapter 0.1.2
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 |
|---|---|---|---|---|
| fcm_adapter-0.1.2.tar.gz | 4.8 kB | Without provenance | Details for fcm_adapter-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fcm_adapter-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for fcm_adapter-0.1.2-py3-none-any.whl |
Total release size: 9.8 kB
Release files / fcm_adapter-0.1.2.tar.gz
| Download URL | fcm_adapter-0.1.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efc162be86285ba1b20ea9f69d11773283e5c6d3588a9e69143c0916e3897980
|
|
BLAKE2b-256 checksum How to use checksums |
e9f2b30cc0f03421fdd008e332e103d9f3985bba3ed589145c2d82b5571df5f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.10.3 Darwin/22.2.0
|
Release files / fcm_adapter-0.1.2-py3-none-any.whl
| Download URL | fcm_adapter-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa9a6aa3bf597c76da694b72ef8a8a77b1c53380d8ab1202c66da89f3f5af1b0
|
|
BLAKE2b-256 checksum How to use checksums |
1753a8df676a96379629c1d1b097af8378527496c0914afe7206cf0f8533a2ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.10.3 Darwin/22.2.0
|
Security for fcm-adapter 0.1.2
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.