Skip to main content

Build Status Coverage Status PyPI version

A very simple Python client for the Pushy notification service API.

Installation

Simply install using pip:

$ pip install PushySDK

or clone this repository and run the following:

$ python setup.py install

You will need to install the following dependencies:

  • requests

  • six

  • pypandoc

This can be done either manually or via pip with the included requirements.txt file as follows:

$ pip install -r requirements.txt

Usage

You will first need to signup for a Pushy account and integrate the Pushy SDK into your Android and/or iOS mobile application (please refer to the comprehensive Pushy Documentation). Once you have successfully sent a test notification from the Pushy Dashboard you are ready to write some python!

First, get your application API key from the Pushy Dashboard (Applications > Your App > API Authentication). Once you have this you can then do the following:

>>> from PushySDK import Pushy
>>> pushy=Pushy('<YOUR_API_KEY>')

You can now request information regarding a specific device (you can get device IDs from the Pushy Dashboard):

>>> pushy.deviceInfo('<YOUR_DEVICE_ID>')

This will return a python dictionary object of information about the device as follows:

{
    'device': {'date': 1445207358, 'platform': 'android'},
    'presence': {
         'online': True,
         'last_active': {'date': 1464006925, 'seconds_ago': 215}
    },
    pending_notifications': [
        {
            'date': 1464008196,
            'expiration': 1466600196,
            'payload': {'message': 'Hello World!'}, 'id': '5742fe0407c3674e226892f9'
        }
    ]
}

You can also return presence information for single or multiple devices as follows:

>>> pushy.devicePresence(['<YOUR_DEVICE_ID>'])
{'presence': [
    {
        'online': False,
        'last_active': 1429406442,
        'id': 'a6f36efb913f1def30c6'
    },
    {
        'online': True,
        'last_active': 1468349965,
        'id': 'fe8f7b2c12e83e5b41d2'
    }
]}

To send a notification to a device or devices:

>>> data={'message':'Hello from Python and Pushy!'}
>>> pushy.push('<YOUR_DEVICE_ID>', data)
>>> pushy.push(['<YOUR_DEVICE_ID_1>', '<YOUR_DEVICE_ID_2>'], data)

To add extra data for iOS APNs notifications, a utility function exists to form the request as follows:

>>> title="Python/Pushy Notification"
>>> message='Hello from Python and Pushy!'
>>> badge=1
>>> sound="ping.aiff"
>>> apn=pushy.makeIOSNotification(message, badge, sound, title)
>>> pushy.push(['<YOUR_ANDROID_DEVICE_ID>', '<YOUR_IOS_DEVICE_ID>'], data, notification=apn)

The push() method will return a dictionary which reports the success or failure and a unique ID for the notification which can be used to track its status:

{'success': True, 'id': '5742ea5dacf3a92e17ba7126'}

You can track a notifications status as follows:

>>> pushy.notificationStatus('<YOUR_NOTIFICATION_ID>')
{
  "push": {
    "date": 1464003935,
    "payload": {
      "message": "Hello World!"
    },
    "expiration": 1466595935,
    "pending_devices": [
      "fe8f7b2c102e883e5b41d2"
    ]
  }
}

Metadata

Release files for PushySDK 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for PushySDK 0.1.5
File Interpreter ABI Platform
PushySDK-0.1.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / PushySDK-0.1.5-py2.py3-none-any.whl

Download URL PushySDK-0.1.5-py2.py3-none-any.whl
Size 6.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
07d506c03c34a97cc5d91a847f1d2178922ce5feb3e2a8db87b20fe400bf9480
BLAKE2b-256 checksum
How to use checksums
59806badb200db2af9034bdf1f394e78f2e4a24ea60928c5dbf26ede8c0181e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.5 This release

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page