|
1 | | -from calendar import c |
2 | 1 | import uuid |
3 | 2 | import firebase_admin |
4 | 3 | from firebase_admin import messaging |
@@ -53,13 +52,13 @@ async def send_message_to_single_device_by_fcm_token( |
53 | 52 | ) |
54 | 53 | if data is None: |
55 | 54 | data = {} |
56 | | - data["title"] = title |
57 | | - data["body"] = body |
58 | 55 | message = messaging.Message( |
| 56 | + notification=messaging.Notification(title=title, body=body), |
59 | 57 | token=fcm_token, |
60 | 58 | data=data, |
61 | 59 | apns=apns, |
62 | 60 | android=android, |
| 61 | + fcm_options=None, |
63 | 62 | ) |
64 | 63 | try: |
65 | 64 | response = messaging.send(message) |
@@ -100,10 +99,9 @@ async def send_message_to_single_device_by_uid( |
100 | 99 |
|
101 | 100 | if data is None: |
102 | 101 | data = {} |
103 | | - data["title"] = title |
104 | | - data["body"] = body |
105 | 102 |
|
106 | 103 | message = messaging.Message( |
| 104 | + notification=messaging.Notification(title=title, body=body), |
107 | 105 | token=user.fcm_token, |
108 | 106 | data=data, |
109 | 107 | apns=apns, |
@@ -152,10 +150,9 @@ async def send_message_to_multiple_devices_by_uid_list( |
152 | 150 |
|
153 | 151 | if data is None: |
154 | 152 | data = {} |
155 | | - data["title"] = title |
156 | | - data["body"] = body |
157 | 153 |
|
158 | 154 | message = messaging.MulticastMessage( |
| 155 | + notification=messaging.Notification(title=title, body=body), |
159 | 156 | tokens=tokens, |
160 | 157 | data=data, |
161 | 158 | apns=apns, |
@@ -198,10 +195,9 @@ async def send_message_to_multiple_devices_by_fcm_token_list( |
198 | 195 | ) |
199 | 196 | if data is None: |
200 | 197 | data = {} |
201 | | - data["title"] = title |
202 | | - data["body"] = body |
203 | 198 |
|
204 | 199 | message = messaging.MulticastMessage( |
| 200 | + notification=messaging.Notification(title=title, body=body), |
205 | 201 | tokens=tokens, |
206 | 202 | data=data, |
207 | 203 | apns=apns, |
@@ -237,10 +233,9 @@ async def send_message_to_topic(topic: str, title: str, body: str, data: dict[st |
237 | 233 | ) |
238 | 234 | if data is None: |
239 | 235 | data = {} |
240 | | - data["title"] = title |
241 | | - data["body"] = body |
242 | 236 |
|
243 | 237 | message = messaging.Message( |
| 238 | + notification=messaging.Notification(title=title, body=body), |
244 | 239 | topic=topic, |
245 | 240 | data=data, |
246 | 241 | apns=apns, |
|
0 commit comments