• Stars
    star
    129
  • Rank 270,656 (Top 6 %)
  • Language
    Python
  • License
    Other
  • Created about 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Push notifications for APNS (iOS) and GCM (Android).

pushjack

version travis coveralls license

Push notifications for APNS (iOS) and GCM (Android).

***WARNING: PROJECT DEPRECATED AND NO LONGER MAINTAINED***

Links

Quickstart

Install using pip:

pip install pushjack

Whether using APNS or GCM, pushjack provides clients for each.

APNS

Send notifications using the APNSClient class:

from pushjack import APNSClient

client = APNSClient(certificate='<path/to/certificate.pem>',
                    default_error_timeout=10,
                    default_expiration_offset=2592000,
                    default_batch_size=100,
                    default_retries=5)

token = '<device token>'
alert = 'Hello world.'

# Send to single device.
# NOTE: Keyword arguments are optional.
res = client.send(token,
                  alert,
                  badge='badge count',
                  sound='sound to play',
                  category='category',
                  content_available=True,
                  title='Title',
                  title_loc_key='t_loc_key',
                  title_loc_args='t_loc_args',
                  action_loc_key='a_loc_key',
                  loc_key='loc_key',
                  launch_image='path/to/image.jpg',
                  extra={'custom': 'data'})

# Send to multiple devices by passing a list of tokens.
client.send([token], alert, **options)

Access response data.

# List of all tokens sent.
res.tokens

# List of errors as APNSServerError objects
res.errors

# Dict mapping errors as token => APNSServerError object.
res.token_errors

Override defaults for error_timeout, expiration_offset, and batch_size.

client.send(token,
            alert,
            expiration=int(time.time() + 604800),
            error_timeout=5,
            batch_size=200)

Send a low priority message.

# The default is low_priority == False
client.send(token, alert, low_priority=True)

Get expired tokens.

expired_tokens = client.get_expired_tokens()

Close APNS connection.

client.close()

For the APNS sandbox, use APNSSandboxClient instead:

from pushjack import APNSSandboxClient

GCM

Send notifications using the GCMClient class:

from pushjack import GCMClient

client = GCMClient(api_key='<api-key>')

registration_id = '<registration id>'
alert = 'Hello world.'
notification = {'title': 'Title', 'body': 'Body', 'icon': 'icon'}

# Send to single device.
# NOTE: Keyword arguments are optional.
res = client.send(registration_id,
                  alert,
                  notification=notification,
                  collapse_key='collapse_key',
                  delay_while_idle=True,
                  time_to_live=604800)

# Send to multiple devices by passing a list of ids.
client.send([registration_id], alert, **options)

Alert can also be be a dictionary with data fields.

alert = {'message': 'Hello world', 'custom_field': 'Custom Data'}

Alert can also contain the notification payload.

alert = {'message': 'Hello world', 'notification': notification}

Send a low priority message.

# The default is low_priority == False
client.send(registration_id, alert, low_priority=True)

Access response data.

# List of requests.Response objects from GCM Server.
res.responses

# List of messages sent.
res.messages

# List of registration ids sent.
res.registration_ids

# List of server response data from GCM.
res.data

# List of successful registration ids.
res.successes

# List of failed registration ids.
res.failures

# List of exceptions.
res.errors

# List of canonical ids (registration ids that have changed).
res.canonical_ids

For more details, please see the full documentation at https://pushjack.readthedocs.io.

More Repositories

1

pydash

The kitchen sink of Python utility libraries for doing "stuff" in a functional way. Based on the Lo-Dash Javascript library.
Python
1,232
star
2

cacheout

A caching library for Python
Python
397
star
3

fnc

Functional programming in Python with generators and other utilities.
Python
228
star
4

hashfs

A content-addressable file management system for Python.
Python
211
star
5

sqlservice

The missing SQLAlchemy ORM interface.
Python
177
star
6

omdb.py

Python wrapper around OMDb API (Open Movie Database): http://omdbapi.com
Python
96
star
7

alchy

The declarative companion to SQLAlchemy
Python
75
star
8

flask-pushjack

Flask extension for push notifications on APNS (iOS) and GCM (Android)
Python
70
star
9

verify

A painless assertion and validation library for Python.
Python
66
star
10

zulu

A drop-in replacement for native Python datetimes that embraces UTC.
Python
60
star
11

yummly.py

Python library for Yummly API: https://developer.yummly.com
Python
28
star
12

shelmet

A shell power-up for working with the file system and running subprocess commands
Python
23
star
13

flask-logconfig

Flask extension for configuring Python logging module
Python
23
star
14

flask-alchy

Flask extension for alchy, the SQLAlchemy enhancement library
Python
16
star
15

logconfig

Simple helper moudle for configuring Python logging
Python
10
star
16

flask-hashfs

Flask extension for HashFS, a content-addressable file management system
Python
7
star
17

pixif

Python script for moving/copying photos from a directory and saving them based on EXIF tag data.
Python
6
star
18

ladder

HTTP client wrapper with URL generation via object notation and argument passing
Python
6
star
19

schemable

Schema validation and parsing library
Python
3
star
20

blog

Source code for my blog
Python
3
star
21

carafe

Flask application factory with extensions geared towards JSON APIs
Python
2
star