forked from pushpad/pushpad-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
31 lines (24 loc) · 1.13 KB
/
Copy pathexample.py
File metadata and controls
31 lines (24 loc) · 1.13 KB
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
30
31
# -*- coding: utf-8 -*-
import pushpad
user1 = 'user1'
user2 = 'user2'
user3 = 'user3'
users = [user1, user2, user3]
tags = ['segment1', 'segment2']
TOKEN='5374d7dfeffa2eb49965624ba7596a09'
PROJ_ID=123
project = pushpad.Pushpad(TOKEN, PROJ_ID)
print("HMAC signature for the uid: %s is: %s" %(user1, project.signature_for(user1)))
print("Subscribe anonymous to push notifications: %s" %(project.path()))
print("Subscribe current user: %s to push notifications: %s" %(user1, project.path_for(user1)))
notification = pushpad.Notification(
project,
body="Hello world!",
title="Website Name",
target_url="http://example.com"
)
print("Send notification to user: %s\nResult: %s" % (user1, notification.deliver_to(user1)))
print("Send notification to users: %s\nResult: %s" % (users, notification.deliver_to(users)))
print("Send broadcast notification\nResult: %s" % notification.broadcast())
print("Send notification to users: %s if they are tagged: %s \nResult: %s" % (users, tags, notification.deliver_to(users, tags=tags)))
print("Send broadcast notification to segments: %s \nResult: %s" % (tags, notification.broadcast(tags=tags)))