-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdemo.py
More file actions
29 lines (21 loc) · 879 Bytes
/
Copy pathdemo.py
File metadata and controls
29 lines (21 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pushy
# Initialize SDK
pushy.listen()
try:
# Register device for push notifications
deviceToken = pushy.register({ 'appId': '550ee57c5b5d72117f51e801' })
# Persist the device token in your backend database
except Exception as err:
# Print error to console
print('Pushy registration error: ' + str(err))
# Define a method to process incoming notifications
def backgroundNotificationListener(data):
# Print notification payload to console
print('Received notification: ' + str(data))
# Execute any custom logic here
# Set up the notification listener
pushy.setNotificationListener(backgroundNotificationListener)
# Avoid program termination (keeps your Python app from terminating until you call pushy.disconnect())
pushy.loop_forever()
# Send yourself a test notification from the demo page
# https://pushy.me/docs/resources/demo