Skip to content

Commit 5356b86

Browse files
committed
fix: Change data-only noti to noti
1 parent bb48d16 commit 5356b86

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

app/services/fcm_service.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from calendar import c
21
import uuid
32
import firebase_admin
43
from firebase_admin import messaging
@@ -53,13 +52,13 @@ async def send_message_to_single_device_by_fcm_token(
5352
)
5453
if data is None:
5554
data = {}
56-
data["title"] = title
57-
data["body"] = body
5855
message = messaging.Message(
56+
notification=messaging.Notification(title=title, body=body),
5957
token=fcm_token,
6058
data=data,
6159
apns=apns,
6260
android=android,
61+
fcm_options=None,
6362
)
6463
try:
6564
response = messaging.send(message)
@@ -100,10 +99,9 @@ async def send_message_to_single_device_by_uid(
10099

101100
if data is None:
102101
data = {}
103-
data["title"] = title
104-
data["body"] = body
105102

106103
message = messaging.Message(
104+
notification=messaging.Notification(title=title, body=body),
107105
token=user.fcm_token,
108106
data=data,
109107
apns=apns,
@@ -152,10 +150,9 @@ async def send_message_to_multiple_devices_by_uid_list(
152150

153151
if data is None:
154152
data = {}
155-
data["title"] = title
156-
data["body"] = body
157153

158154
message = messaging.MulticastMessage(
155+
notification=messaging.Notification(title=title, body=body),
159156
tokens=tokens,
160157
data=data,
161158
apns=apns,
@@ -198,10 +195,9 @@ async def send_message_to_multiple_devices_by_fcm_token_list(
198195
)
199196
if data is None:
200197
data = {}
201-
data["title"] = title
202-
data["body"] = body
203198

204199
message = messaging.MulticastMessage(
200+
notification=messaging.Notification(title=title, body=body),
205201
tokens=tokens,
206202
data=data,
207203
apns=apns,
@@ -237,10 +233,9 @@ async def send_message_to_topic(topic: str, title: str, body: str, data: dict[st
237233
)
238234
if data is None:
239235
data = {}
240-
data["title"] = title
241-
data["body"] = body
242236

243237
message = messaging.Message(
238+
notification=messaging.Notification(title=title, body=body),
244239
topic=topic,
245240
data=data,
246241
apns=apns,

0 commit comments

Comments
 (0)