-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpusher.py
More file actions
45 lines (37 loc) · 1.19 KB
/
pusher.py
File metadata and controls
45 lines (37 loc) · 1.19 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pyrebase
from pusher_push_notifications import PushNotifications
config = {
'apiKey': "AIzaSyAhw2kHSFjIm4L3ZFbmhPCpw5mScEksDc8",
'authDomain': "esri-eea51.firebaseapp.com",
'databaseURL': "https://esri-eea51.firebaseio.com",
'projectId': "esri-eea51",
'storageBucket': "esri-eea51.appspot.com",
'messagingSenderId': "457374308934"
}
firebase = pyrebase.initialize_app(config)
db=firebase.database()
pn_client = PushNotifications(
instance_id='61d2753d-9e78-4bc5-86d4-61e44fedab27',
secret_key='1B3432CB3D025DCFB2FFC1CA9204EAB',
)
def stream_handler(message):
print(message)
if(message['data'] is 1):
response = pn_client.publish(
interests=['hello'],
publish_body={
'apns': {
'aps': {
'alert': 'Hello!',
},
},
'fcm': {
'notification': {
'title': 'Hello',
'body': 'Hello, world!',
},
},
},
)
print(response['publishId'])
my_stream = db.child("fire_sensor_status").stream(stream_handler,None)