fix: honour silent push mode for data-only FCM (0.4.7)
Handle notifications synchronously in onMessageReceived and read title/body from data payload sent by SAC. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,8 +13,8 @@ android {
|
|||||||
applicationId = "ru.kalinamall.seaca"
|
applicationId = "ru.kalinamall.seaca"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 10
|
versionCode = 11
|
||||||
versionName = "0.4.6"
|
versionName = "0.4.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import ru.kalinamall.seaca.data.NotificationMode
|
import ru.kalinamall.seaca.data.NotificationMode
|
||||||
import ru.kalinamall.seaca.data.SacRepository
|
import ru.kalinamall.seaca.data.SacRepository
|
||||||
|
|
||||||
@@ -14,19 +15,18 @@ class SeacaMessagingService : FirebaseMessagingService() {
|
|||||||
private val repo by lazy { SacRepository(applicationContext) }
|
private val repo by lazy { SacRepository(applicationContext) }
|
||||||
|
|
||||||
override fun onMessageReceived(message: RemoteMessage) {
|
override fun onMessageReceived(message: RemoteMessage) {
|
||||||
scope.launch {
|
val mode = runBlocking { repo.session.getNotificationMode() }
|
||||||
when (repo.session.getNotificationMode()) {
|
when (mode) {
|
||||||
NotificationMode.OFF -> return@launch
|
NotificationMode.OFF -> return
|
||||||
NotificationMode.PUSH_SILENT -> show(message, silent = true)
|
NotificationMode.PUSH_SILENT -> show(message, silent = true)
|
||||||
NotificationMode.PUSH_SOUND -> show(message, silent = false)
|
NotificationMode.PUSH_SOUND -> show(message, silent = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun show(message: RemoteMessage, silent: Boolean) {
|
private fun show(message: RemoteMessage, silent: Boolean) {
|
||||||
val data = message.data
|
val data = message.data
|
||||||
val title = message.notification?.title ?: data["title"] ?: "SAC"
|
val title = data["title"] ?: message.notification?.title ?: "SAC"
|
||||||
val body = message.notification?.body ?: data["body"] ?: ""
|
val body = data["body"] ?: message.notification?.body ?: ""
|
||||||
NotificationHelper.show(
|
NotificationHelper.show(
|
||||||
context = this,
|
context = this,
|
||||||
title = title,
|
title = title,
|
||||||
|
|||||||
Reference in New Issue
Block a user