Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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.

Features

  • Uses the new Apple APNs HTTP/2 protocol
  • Supports the new iOS 10 features such as Collapse IDs, Subtitles and Mutable Notifications
  • Supports persistent connections to APNS

Cautions

  • Works only with Python 3.5 and higher

Installation

Install using pip:

pip install pyapns_client

Usage

from pyapns_client import APNSClient, IOSPayloadAlert, IOSPayload, IOSNotification, APNSException, UnregisteredException


cli = APNSClient(mode=APNSClient.MODE_DEV, client_cert='/your/path.pem')
alert = IOSPayloadAlert(body='body!', title='title!')
payload = IOSPayload(alert=alert)
notification = IOSNotification(payload=payload, priority=IOSNotification.PRIORITY_LOW)

try:
    cli.push(notification=notification, device_token='your_token')
except APNSException as e:
    if e.is_device_error:
        if isinstance(e, UnregisteredException):
            # device is unregistered, compare timestamp (e.timestamp_datetime) and remove from db
            pass
        else:
            # flag the device as potentially invalid
            pass
    elif e.is_apns_error:
        # try again later
        pass
    elif e.is_programming_error:
        # check your code
        # try again later
        pass
else:
    # everything is ok
    pass

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 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size pyapns_client-1.0.3.tar.gz (7.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page