Full documentation for this SDK can be found here
The Pusher Beams Python server SDK is available on PyPi here.
You can install this SDK by using pip:
$ pip install pusher_push_notifications
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
beams_client = PushNotifications(
instance_id='YOUR_INSTANCE_ID_HERE',
secret_key='YOUR_SECRET_KEY_HERE',
)
You can broadcast notifications to groups of subscribed devices using Device Interests:
response = beams_client.publish_to_interests(
interests=['hello'],
publish_body={
'apns': {
'aps': {
'alert': 'Hello!'
}
},
'fcm': {
'notification': {
'title': 'Hello',
'body': 'Hello, World!'
}
}
}
)
print(response['publishId'])
Securely send notifications to individual users of your application using Authenticated Users:
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'])