一个通过HTTP/2协议与Apple Push Notification Service(APNs)交互的Python库
项目描述
compat-fork-apns2
这是一个apns2库的分支,以提供与较新版本的Python和pyjwt库的兼容性。它由compat-fork项目维护。
compat-fork变更日志
- 版本 0.8.0
- 与上游
master
没有重大的代码更改 - 不再声明支持Python 3.7(它可能仍然工作,但我们不再支持不受支持的Python版本)
- 支持pyjwt 2
- 与上游
原始README
PyAPNs2
通过HTTP/2协议与Apple Push Notification服务(APNs)交互的Python库
安装
您可以从GitHub下载源代码或使用pip
$ pip install apns2
示例用法
from apns2.client import APNsClient
from apns2.payload import Payload
token_hex = 'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b87'
payload = Payload(alert="Hello World!", sound="default", badge=1)
topic = 'com.example.App'
client = APNsClient('key.pem', use_sandbox=False, use_alternative_port=False)
client.send_notification(token_hex, payload, topic)
# To send multiple notifications in a batch
Notification = collections.namedtuple('Notification', ['token', 'payload'])
notifications = [Notification(payload=payload, token=token_hex)]
client.send_notification_batch(notifications=notifications, topic=topic)
# To use token based authentication
from apns2.credentials import TokenCredentials
auth_key_path = 'path/to/auth_key'
auth_key_id = 'app_auth_key_id'
team_id = 'app_team_id'
token_credentials = TokenCredentials(auth_key_path=auth_key_path, auth_key_id=auth_key_id, team_id=team_id)
client = APNsClient(credentials=token_credentials, use_sandbox=False)
client.send_notification_batch(notifications=notifications, topic=topic)
更多信息
贡献
要开发PyAPNs2,请检出代码并安装依赖项。建议使用virtualenv来隔离依赖项
# Clone the source code.
git clone https://github.com/Pr0Ger/PyAPNs2.git
cd PyAPNs2
# Create a virtualenv and install dependencies.
virtualenv venv
. venv/bin/activate
pip install -e .[tests]
要运行测试
pytest
您可以使用tox
在所有支持的Python版本上运行测试
pyenv install 3.5.6; pyenv install 3.6.7; pyenv install 3.7.1; pyenv install 3.8.0
pyenv local 3.8.0 3.7.1 3.6.7 3.5.6
pip install tox
tox
要运行lint
pip install pylint
pylint --reports=n apns2 test
许可证
PyAPNs2是在MIT许可证下分发的。
有关完整的许可证详情,请参阅LICENSE文件。
项目详情
关闭
compat_fork_apns2-0.8.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e5605ee95e6926b31c49192b30decaf7b44756dfc503d1a04285d268423a9cb2 |
|
MD5 | 2970103cce6218763da00512819d3933 |
|
BLAKE2b-256 | a82dbe46aa05a29b6addcac5da1dd66e928c6412a4c30ee433b5f71c9e13af2b |
关闭
compat_fork_apns2-0.8.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bfacd4f2802ccdff6f848c99930096b2bb2a363a9adf4b27048a78721b00875f |
|
MD5 | 74006efafd80202a8cf106ecd49821a8 |
|
BLAKE2b-256 | 107c7221fca0abb4ff2d90c8cd687f959c866d9589bd4b6bd08acf32556a329b |