**************
pyapns_client3
**************
|version| |license|
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
- Supports token-based authentication (no need to renew your certificates anymore) and certificate-based authentication
- 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
- Supports asynchronous sending of notifications
Cautions
========
- Works only with Python 3.6 and higher
Installation
============
Install using pip:
.. code-block:: bash
pip install pyapns_client3
Usage
=====
Sync
----
.. code-block:: python
from pyapns_client import APNSClient, TokenBasedAuth, IOSPayloadAlert, IOSPayload, IOSNotification, APNSDeviceException, APNSServerException, APNSProgrammingException, UnregisteredException
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')
# `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
with APNSClient(
mode=APNSClient.MODE_DEV,
authentificator=TokenBasedAuth(
auth_key_path='/path/to/auth_key.p8',
auth_key_id='AUTHKEY123',
team_id='TEAMID1234'
),
root_cert_path='/path/to/root_cert.pem',
) as client:
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')
Async
-----
.. code-block:: python
from pyapns_client import AsyncAPNSClient, TokenBasedAuth, IOSPayloadAlert, IOSPayload, IOSNotification, APNSDeviceException, APNSServerException, APNSProgrammingException, UnregisteredException
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')
# `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
async with AsyncAPNSClient(
mode=APNSClient.MODE_DEV,
authentificator=TokenBasedAuth(
auth_key_path='/path/to/auth_key.p8',
auth_key_id='AUTHKEY123',
team_id='TEAMID1234'
),
root_cert_path='/path/to/root_cert.pem',
) as client:
for device_token in device_tokens:
try:
await 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')
.. |version| image:: https://img.shields.io/pypi/v/pyapns_client3.svg?style=flat-square
:target: https://pypi.python.org/pypi/pyapns_client3/
.. |license| image:: https://img.shields.io/pypi/l/pyapns_client3.svg?style=flat-square
:target: https://pypi.python.org/pypi/pyapns_client3/
3.0
===
3.0.6
-----
Changed
^^^^^^^
- allow to use `str` as alert for notification payload (by @tartansandal)
Added
^^^^^
- some tests with Python version 3.6-3.11
- some payload serialization tests (by @tartansandal)
- some type annotations
- some docstrings
3.0.5
-----
Fixed
^^^^^
- have `auth.py` use the `Dict` type hint from the typing module by @tinycogio
3.0.0
-----
Refactored
^^^^^^^^^^
- extract authentication classes
2.1
===
2.1.0
-----
Added
^^^^^
- async/await support with `AsyncAPNSClient`
2.0
===
2.0.7
-----
Added
^^^^^
- usage as context manager
- certificate-based authentication
Raw data
{
"_id": null,
"home_page": "https://github.com/capcom6/pyapns_client",
"name": "pyapns-client3",
"maintainer": "Aleksandr Soloshenko",
"docs_url": null,
"requires_python": "",
"maintainer_email": "capcom2me@gmail.com",
"keywords": "apns apple ios osx safari push notifications",
"author": "Jakub Kle\u0148",
"author_email": "kukosk@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/79/b1/b0fe33d6d130f4fd4ed39f08b06102de32ac361c331fa71f63a315382bf2/pyapns_client3-3.0.6.tar.gz",
"platform": "any",
"description": "**************\npyapns_client3\n**************\n\n|version| |license|\n\nSimple, flexible and fast Apple Push Notifications on iOS, OSX and Safari using the HTTP/2 Push provider API.\n\n\nFeatures\n========\n\n- Uses the new Apple APNs HTTP/2 protocol with persistent connections\n- Supports token-based authentication (no need to renew your certificates anymore) and certificate-based authentication\n- Uses the httpx HTTP client library\n- Supports the new iOS 10 features such as Collapse IDs, Subtitles and Mutable Notifications\n- Makes the integration and error handling really simple with auto-retry on APNs errors\n- Supports asynchronous sending of notifications\n\n\nCautions\n========\n\n- Works only with Python 3.6 and higher\n\n\nInstallation\n============\n\nInstall using pip:\n\n.. code-block:: bash\n\n pip install pyapns_client3\n\n\nUsage\n=====\n\nSync\n----\n\n.. code-block:: python\n\n from pyapns_client import APNSClient, TokenBasedAuth, IOSPayloadAlert, IOSPayload, IOSNotification, APNSDeviceException, APNSServerException, APNSProgrammingException, UnregisteredException\n\n\n device_tokens = ['device_token_1', 'device_token_2']\n alert = IOSPayloadAlert(title='Title', subtitle='Subtitle', body='Some message.')\n payload = IOSPayload(alert=alert)\n notification = IOSNotification(payload=payload, topic='domain.organization.app')\n\n # `root_cert_path` is for the AAACertificateServices root cert (https://apple.co/3mZ5rB6)\n # with token-based auth you don't need to create / renew your APNS SSL certificates anymore\n # you can pass `None` to `root_cert_path` if you have the cert included in your trust store\n # httpx uses 'SSL_CERT_FILE' and 'SSL_CERT_DIR' from `os.environ` to find your trust store\n with APNSClient(\n mode=APNSClient.MODE_DEV, \n authentificator=TokenBasedAuth(\n auth_key_path='/path/to/auth_key.p8', \n auth_key_id='AUTHKEY123', \n team_id='TEAMID1234'\n ),\n root_cert_path='/path/to/root_cert.pem', \n ) as client:\n for device_token in device_tokens:\n try:\n client.push(notification=notification, device_token=device_token)\n except UnregisteredException as e:\n print(f'device is unregistered, compare timestamp {e.timestamp_datetime} and remove from db')\n except APNSDeviceException:\n print('flag the device as potentially invalid and remove from db after a few tries')\n except APNSServerException:\n print('try again later')\n except APNSProgrammingException:\n print('check your code and try again later')\n else:\n print('everything is ok')\n\nAsync\n-----\n\n.. code-block:: python\n\n from pyapns_client import AsyncAPNSClient, TokenBasedAuth, IOSPayloadAlert, IOSPayload, IOSNotification, APNSDeviceException, APNSServerException, APNSProgrammingException, UnregisteredException\n\n\n device_tokens = ['device_token_1', 'device_token_2']\n alert = IOSPayloadAlert(title='Title', subtitle='Subtitle', body='Some message.')\n payload = IOSPayload(alert=alert)\n notification = IOSNotification(payload=payload, topic='domain.organization.app')\n\n # `root_cert_path` is for the AAACertificateServices root cert (https://apple.co/3mZ5rB6)\n # with token-based auth you don't need to create / renew your APNS SSL certificates anymore\n # you can pass `None` to `root_cert_path` if you have the cert included in your trust store\n # httpx uses 'SSL_CERT_FILE' and 'SSL_CERT_DIR' from `os.environ` to find your trust store\n async with AsyncAPNSClient(\n mode=APNSClient.MODE_DEV, \n authentificator=TokenBasedAuth(\n auth_key_path='/path/to/auth_key.p8', \n auth_key_id='AUTHKEY123', \n team_id='TEAMID1234'\n ),\n root_cert_path='/path/to/root_cert.pem', \n ) as client:\n for device_token in device_tokens:\n try:\n await client.push(notification=notification, device_token=device_token)\n except UnregisteredException as e:\n print(f'device is unregistered, compare timestamp {e.timestamp_datetime} and remove from db')\n except APNSDeviceException:\n print('flag the device as potentially invalid and remove from db after a few tries')\n except APNSServerException:\n print('try again later')\n except APNSProgrammingException:\n print('check your code and try again later')\n else:\n print('everything is ok')\n\n.. |version| image:: https://img.shields.io/pypi/v/pyapns_client3.svg?style=flat-square\n :target: https://pypi.python.org/pypi/pyapns_client3/\n\n.. |license| image:: https://img.shields.io/pypi/l/pyapns_client3.svg?style=flat-square\n :target: https://pypi.python.org/pypi/pyapns_client3/\n\n\n3.0\n===\n3.0.6\n-----\nChanged\n^^^^^^^\n- allow to use `str` as alert for notification payload (by @tartansandal)\n\nAdded\n^^^^^\n- some tests with Python version 3.6-3.11\n- some payload serialization tests (by @tartansandal)\n- some type annotations\n- some docstrings\n\n3.0.5\n-----\n\nFixed\n^^^^^\n- have `auth.py` use the `Dict` type hint from the typing module by @tinycogio\n\n3.0.0\n-----\n\nRefactored\n^^^^^^^^^^\n- extract authentication classes\n\n2.1\n===\n2.1.0\n-----\n\nAdded\n^^^^^\n- async/await support with `AsyncAPNSClient`\n\n2.0\n===\n2.0.7\n-----\n\nAdded\n^^^^^\n- usage as context manager\n- certificate-based authentication\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Simple, flexible and fast Apple Push Notifications on iOS, OSX and Safari using the HTTP/2 Push provider API with async support.",
"version": "3.0.6",
"project_urls": {
"Homepage": "https://github.com/capcom6/pyapns_client"
},
"split_keywords": [
"apns",
"apple",
"ios",
"osx",
"safari",
"push",
"notifications"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "749f44f681b2c8d1b380d8a070963750a6fcf2673225d7e46f174ec551adc42e",
"md5": "cc262a320a80cdab9fd1a93fe6d5a300",
"sha256": "efc0fd4bfb5188bc92443876ee4c6cb8f0174110abb76dff651663b46e65efcd"
},
"downloads": -1,
"filename": "pyapns_client3-3.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cc262a320a80cdab9fd1a93fe6d5a300",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 14583,
"upload_time": "2023-05-15T02:51:42",
"upload_time_iso_8601": "2023-05-15T02:51:42.123028Z",
"url": "https://files.pythonhosted.org/packages/74/9f/44f681b2c8d1b380d8a070963750a6fcf2673225d7e46f174ec551adc42e/pyapns_client3-3.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "79b1b0fe33d6d130f4fd4ed39f08b06102de32ac361c331fa71f63a315382bf2",
"md5": "9d9334f45e86be0256e8f089c3bdb0f0",
"sha256": "9acea0356043e6c01fa7642e0ddc3671259927476cd9a0601749c509f7b59b0d"
},
"downloads": -1,
"filename": "pyapns_client3-3.0.6.tar.gz",
"has_sig": false,
"md5_digest": "9d9334f45e86be0256e8f089c3bdb0f0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13678,
"upload_time": "2023-05-15T02:51:43",
"upload_time_iso_8601": "2023-05-15T02:51:43.805478Z",
"url": "https://files.pythonhosted.org/packages/79/b1/b0fe33d6d130f4fd4ed39f08b06102de32ac361c331fa71f63a315382bf2/pyapns_client3-3.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-15 02:51:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "capcom6",
"github_project": "pyapns_client",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyapns-client3"
}