-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirebaseMessaging.py
52 lines (41 loc) · 1.18 KB
/
firebaseMessaging.py
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
46
47
48
49
50
51
52
# Shivoy Arora
# ~/Programs/Swift/Evilator/firebaseMessaging.py
#
# For sending cloud messages via firebase
import firebase_admin
from firebase_admin import messaging, credentials
Topics = [
"pushNoti",
"removeAdNoti",
"personalNoti"
]
def setupEvilator():
cred = credentials.Certificate("./evilator-firebase-adminsdk.json")
firebase_admin.initialize_app(cred)
def sendToTopic(topic, title, body):
message = messaging.Message(
topic = topic,
notification = messaging.Notification(
title = title,
body = body
),
apns= messaging.APNSConfig(
payload=messaging.APNSPayload(
aps=messaging.Aps(
sound='default'
)
)
),
)
response = messaging.send(message)
print("Sent message:", response)
if __name__ == "__main__":
setupEvilator()
print("Select Topic: ")
for i in range(0,len(Topics)):
print(i+1,":",Topics[i])
topicIndex = int(input("Enter the topic index: "))
topic = Topics[topicIndex - 1]
title = input("Enter title: ")
body = input("Enter body: ")
sendToTopic(topic, title, body)