一个高效的火焰云消息客户端库
aiofcm的Python项目详细描述
aiofcm是专为发送推送通知等消息而设计的库 通过firebase云消息平台发送到android设备。aiofcm提供了一个高效的客户机 通过与python的^{tt1}一起使用的异步xmpp协议$ 框架
aiofcm需要Python 3.5或更高版本
性能
在我的测试中,aiofcm允许您在单个内核上平均每秒发送1k条消息。
功能
- 适应当前负载的内部连接池
- 发送通知和/或数据消息
- 能够为消息设置TTL(生存时间)
- 能够设置消息的优先级
- 能够为消息设置折叠键
安装
使用PIP安装:
$ pip install aiofcm
基本用法
fromuuidimportuuid4fromaiofcmimportFCM,Message,PRIORITY_HIGHasyncdefrun():fcm=FCM('<NUMERICAL_SENDER_ID>','<API_KEY>')message=Message(device_token='<DEVICE_TOKEN>',notification={# optional"title":"Hello from Firebase","body":"This is notification","sound":"default"},data={"score":"3x1"},# optionalmessage_id=str(uuid4())# optionaltime_to_live=3,# optionalpriority=PRIORITY_HIGH,# optional)awaitfcm.send_message(message)loop=asyncio.get_event_loop()loop.run_until_complete(run())
许可证
aiofcm是在Apache 2.0许可下开发和分发的