Skip to main content

Python client for Apple Push Notification service (APNs)

Project description

Python client for Apple Push Notification service (APNs). Check documentation to learn how to use it.

Check the client with similar interface for Google Cloud Messaging.

Requirements

  • six - Python 2 and 3 compatibility library.

  • pyOpenSSL - OpenSSL wrapper. Required by standard networking back-end.

Standard library has support for SSL transport. However, it is impossible to use it with certificates provided as a string. We store certificates in database, because we handle different apps on many Celery worker machines. A dirty solution would be to create temporary files, but it is insecure and slow. So, we have decided to use a better OpenSSL wrapper and pyOpenSSL was the easiest to handle. pyOpenSSL is loaded on demand by standard networking back-end. If you use your own back-end, based on some other SSL implementation, then you don’t have to install pyOpenSSL.

Alternatives

There are many alternatives available. We have started with pyapns and APNSWrapper. This library differs in the following design decisions:

  • Support certificates from strings. We do not distribute certificate files on worker machines, they fetch it from the database when needed. This approach simplifies deployment, upgrades and maintenance.

  • Keep connections persistent. An SSL handshaking round is slow. Once connection is established, it should remain open for at least few minutes, waiting for the next batch.

  • Support enhanced format. Apple developers have designed a notoriously bad push protocol. They have upgraded it to enhanced version, which makes it possible to detect which messages in the batch have failed.

  • Clean pythonic API. No need for lots of classes, long lists of exceptions etc.

  • Do not hard-code validation, let APNs fail. This decision makes library a little bit more future proof.

Changelog

v0.2

Networking layer became pluggable, making gevent based implementations possible. Everything is refactored, such that IO, multi-threading and SSL are now loaded and used on demand, allowing you to cleanly override any part of the client. The API is largely backward compatible. IO related configuration is moved to transport layer and exception handling is a bit more verbose. The client is using standard logging to send fine grained debug messages.

v0.1

First simple implementation, hardwired with raw sockets and pyOpenSSL. It does not work in gevent or any other green environment.

Support

APNs client was created by Sardar Yumatov, contact me if you find any bugs or need help. Contact Getlogic if you need a full-featured push notification service for all popular platforms. You can view outstanding issues on the APNs Bitbucket page.

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

apns-client-0.2.1.tar.gz (33.4 kB view details)

Uploaded Source

File details

Details for the file apns-client-0.2.1.tar.gz.

File metadata

  • Download URL: apns-client-0.2.1.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for apns-client-0.2.1.tar.gz
Algorithm Hash digest
SHA256 42ece7fa61b216f7b7140a33a651df57230a6cfbbf4b9e4a2d2a61275701aa58
MD5 11b4b21c95b0bfa10ac0edf692aee551
BLAKE2b-256 6cf9e142ea0110d3d056dd8fae3ce2606b71ac0c1e035dc4c058aa9373fe21d3

See more details on using hashes here.

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