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.

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.

Source Distribution

pyapns_client-1.0.3.tar.gz (7.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page