Simple, flexible and fast Apple Push Notifications on iOS, OSX and Safari using the HTTP/2 Push provider API.
Features
Uses the new Apple APNs HTTP/2 protocol with persistent connections
Uses token-based authentication (no need to renew your certificates anymore)
Uses the httpx HTTP client library
Supports the new iOS 10 features such as Collapse IDs, Subtitles and Mutable Notifications
Makes the integration and error handling really simple with auto-retry on APNs errors
Cautions
Works only with Python 3.6 and higher
Installation
Install using pip:
pip install pyapns_client
Usage
from pyapns_client import APNSClient, IOSPayloadAlert, IOSPayload, IOSNotification, APNSDeviceException, APNSServerException, APNSProgrammingException, UnregisteredException
client = APNSClient(mode=APNSClient.MODE_DEV, root_cert_path='/path/to/root_cert.pem', auth_key_path='/path/to/auth_key.p8', auth_key_id='AUTHKEY123', team_id='TEAMID1234')
# `root_cert_path` is for the AAACertificateServices root cert (https://apple.co/3mZ5rB6)
# with token-based auth you don't need to create / renew your APNS SSL certificates anymore
# you can pass `None` to `root_cert_path` if you have the cert included in your trust store
# httpx uses 'SSL_CERT_FILE' and 'SSL_CERT_DIR' from `os.environ` to find your trust store
try:
device_tokens = ['device_token_1', 'device_token_2']
alert = IOSPayloadAlert(title='Title', subtitle='Subtitle', body='Some message.')
payload = IOSPayload(alert=alert)
notification = IOSNotification(payload=payload, topic='domain.organization.app')
for device_token in device_tokens:
try:
client.push(notification=notification, device_token=device_token)
except UnregisteredException as e:
print(f'device is unregistered, compare timestamp {e.timestamp_datetime} and remove from db')
except APNSDeviceException:
print('flag the device as potentially invalid and remove from db after a few tries')
except APNSServerException:
print('try again later')
except APNSProgrammingException:
print('check your code and try again later')
else:
print('everything is ok')
finally:
client.close()
Metadata
Release files for pyapns-client 2.0.6
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 | |
|---|---|---|---|---|
| pyapns_client-2.0.6.tar.gz | 10.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyapns_client-2.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.1 kB
Release files / pyapns_client-2.0.6.tar.gz
| Download URL | pyapns_client-2.0.6.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bba1820fe0e4e7d3ff587455444357d5dbc6b5ec2b5b8a49c7a89a8ea7eb8218
|
|
BLAKE2b-256 checksum How to use checksums |
f037e827158524c6b70115a93c1846186643daceafcc1a0a9ae4d4b87071fb09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Release files / pyapns_client-2.0.6-py3-none-any.whl
| Download URL | pyapns_client-2.0.6-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c61e0c6504e653410b9178912f2063e359f2ec384b6f487c1c29f5d4d41eb79
|
|
BLAKE2b-256 checksum How to use checksums |
c534079c0e5cc7ad39ba80c30f8aad51dc48c182d3350287244fc28f60258199
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Security for pyapns-client 2.0.6
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.