https://github.com/pusher/push-notifications-python
Pusher Beams Python Server SDK
https://github.com/pusher/push-notifications-python
push-notifications pusher python python2 python3
Last synced: 12 months ago
JSON representation
Pusher Beams Python Server SDK
- Host: GitHub
- URL: https://github.com/pusher/push-notifications-python
- Owner: pusher
- License: mit
- Created: 2018-01-04T21:36:39.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-06T16:58:47.000Z (about 1 year ago)
- Last Synced: 2025-03-29T18:08:22.983Z (12 months ago)
- Topics: push-notifications, pusher, python, python2, python3
- Language: Python
- Homepage: https://pusher.com/beams
- Size: 85 KB
- Stars: 31
- Watchers: 12
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
.. image:: https://github.com/pusher/push-notifications-python/workflows/CI/badge.svg
:target: https://github.com/pusher/push-notifications-python/actions?query=branch%3Amaster
.. image:: https://codecov.io/gh/pusher/push-notifications-python/branch/master/graph/badge.svg
:target: https://codecov.io/gh/pusher/push-notifications-python
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 `__:
.. code::
$ 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:
.. code::
from pusher_push_notifications import PushNotifications
beams_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 `__:
.. code::
response = beams_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 `__:
.. code::
response = beams_client.publish_to_users(
user_ids=['user-0001'],
publish_body={
'apns': {
'aps': {
'alert': 'Hello!'
}
},
'fcm': {
'notification': {
'title': 'Hello',
'body': 'Hello, World!'
}
}
}
)
print(response['publishId'])