Skip to main content

Simple, flexible and fast Apple Push Notifications on iOS, OSX and Safari using the HTTP/2 Push provider API.

Project description

version license

Simple, flexible and fast Apple Push Notifications on iOS, OSX and Safari using the HTTP/2 Push provider API.


  • Uses the new Apple APNs HTTP/2 protocol with persistent connections
  • Uses token-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


  • Works only with Python 3.6 and higher


Install using pip:

pip install pyapns_client


from pyapns_client import APNSClient, IOSPayloadAlert, IOSPayload, IOSNotification, APNSDeviceException, APNSServerException, APNSProgrammingException, UnregisteredException

client = APNSClient(mode=APNSClient.MODE_DEV, root_cert_path='/your/path.pem', auth_key_path='/your/path.p8', auth_key_id='AUTHKEY123', team_id='TEAMID1234')
# you can pass `None` to `root_cert_path` if you have the cert included in your trust store

    device_tokens = ['your_token1', 'your_token2']
    alert = IOSPayloadAlert(body='Some message.', title='Title')
    payload = IOSPayload(alert=alert)
    notification = IOSNotification(payload=payload, topic='')

    for device_token in device_tokens:
            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')
            print('everything is ok')

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyapns-client, version 2.0.2
Filename, size File type Python version Upload date Hashes
Filename, size pyapns_client-2.0.2.tar.gz (10.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page