Skip to main content

Pusher Push Notifications Python server SDK

Project description

https://travis-ci.org/pusher/push-notifications-python.svg?branch=master https://codecov.io/gh/pusher/push-notifications-python/branch/master/graph/badge.svg

Pusher Beams Python server SDK

Full documentation for this SDK can be found here

Installation

The Pusher Beams Python server SDK is available on PyPi here.

You can install this SDK by using pip:

$ pip install pusher_push_notifications

Usage

Configuring the SDK for Your Instance

Use your instance id and secret (you can get these from the dashboard) to create a Beams PushNotifications instance:

from pusher_push_notifications import PushNotifications

pn_client = PushNotifications(
    instance_id='YOUR_INSTANCE_ID_HERE',
    secret_key='YOUR_SECRET_KEY_HERE',
)

Publishing to Device Interests

You can broadcast notifications to groups of subscribed devices using Device Interests:

response = pn_client.publish_to_interests(
    interests=['hello'],
    publish_body={
        'apns': {
            'aps': {
                'alert': 'Hello!'
            }
        },
        'fcm': {
            'notification': {
                'title': 'Hello',
                'body': 'Hello, World!'
            }
        }
    }
)

print(response['publishId'])

Publishing to Authenticated Users

Securely send notifications to individual users of your application using Authenticated Users:

response = pn_client.publish_to_users(
    user_ids=['user-0001'],
    publish_body={
        'apns': {
            'aps': {
                'alert': 'Hello!'
            }
        },
        'fcm': {
            'notification': {
                'title': 'Hello',
                'body': 'Hello, World!'
            }
        }
    }
)

print(response['publishId'])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pusher-push-notifications, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size pusher_push_notifications-1.1.0-py2.py3-none-any.whl (6.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size pusher_push_notifications-1.1.0.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page