Giter Club home page Giter Club logo

applepushnotification's Introduction

Apple Push Notification Service connector for Python
================================================================================

An APNS connector which just works. The following items are supported:

 - Extended APNS message (most Python APNS libraries only support basic format)
 - Expiry date on notifications
 - Custom data fields
 - Unicode messages
 - Error reporting
 - Automatic feedback handling

The biggest differentiator between this connector and other libraries is that
the programmer doesn't have to manage individual APNS connections or wrappers.
This connector will reconnect to send notifications automatically, and maintain
connections opportunistically for good performance.

Depends on gevent and expects coroutine I/O style.

* This library and its author are not affiliated with Apple Inc.


Usage Example
================================================================================

This connector is expected to be used in a Python network service which uses
gevent for I/O. For example, a gevent.pywsgi web server running Pylons. In this
case the connector will open a few greenlets for sending push notifications and
receiving replies from APNS servers.

If you're testing the library from command line or from a stand-alone script,
you'll need to make some way to let gevent switch to the library's greenlets
during message send. The recommended way to do this is to call wait_send():

>>> from applepushnotification import *
>>> service = NotificationService(certfile="<cert/key bundle in PEM format>")
>>> service.start()
>>> token = "<hex encoded device token from Apple>".decode("hex")
>>> message = NotificationMessage(token, u"Hello World!")
>>> service.send(message)
>>> service.wait_send()
>>> ... send a few more messages here ...
>>> service.stop()      # this implies a wait_send() as well

Assume the PEM certificate and the device token are set correctly, and that
you have the corresponding iOS app installed on the device, you should see a
Hello World message within a few seconds.

wait_send() is generally not needed when you're using the library in a gevent
based network service. The reason being that your network service would normally
spend time waiting for network activity, during which gevent's scheduler will
switch to scheduled greenlets such that the connector can send messages out in
the background.

If you're not familiar with coroutine I/O and gevent, please refer to gevent's
documentation at http://www.gevent.org/

applepushnotification's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.