fix: send android pushes as data-only fcm messages
Some checks failed
Android CI / android (push) Failing after 4m59s
Android Release / release (push) Failing after 4m31s
CI / test (push) Failing after 2m29s

- include title and body in FCM data payload for Android

- use high priority Android config so the app builds notifications itself
This commit is contained in:
2026-04-05 23:34:10 +03:00
parent a411d17cf0
commit 4a28d3d495

View File

@@ -80,18 +80,30 @@ def _send_fcm_to_user(user_id: int, title: str, body: str, data: dict[str, Any])
if not tokens:
return
string_data = {str(key): str(value) for key, value in data.items()}
string_data = {
**{str(key): str(value) for key, value in data.items()},
"title": title,
"body": body,
}
for platform, token in tokens:
webpush = None
notification = None
android = None
if platform == "web":
webpush = messaging.WebpushConfig(
fcm_options=messaging.WebpushFCMOptions(link=settings.firebase_webpush_link)
)
notification = messaging.Notification(title=title, body=body)
elif platform == "android":
android = messaging.AndroidConfig(priority="high")
else:
notification = messaging.Notification(title=title, body=body)
message = messaging.Message(
token=token,
notification=messaging.Notification(title=title, body=body),
notification=notification,
data=string_data,
webpush=webpush,
android=android,
)
try:
messaging.send(message, app=app)