fix: clear SAC push notifications when app is opened (0.5.15)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
PTah
2026-06-23 19:09:39 +10:00
parent c0842eb84b
commit 0f05c3b2c3
4 changed files with 13 additions and 4 deletions
+2 -2
View File
@@ -13,8 +13,8 @@ android {
applicationId = "ru.kalinamall.seaca" applicationId = "ru.kalinamall.seaca"
minSdk = 26 minSdk = 26
targetSdk = 35 targetSdk = 35
versionCode = 28 versionCode = 29
versionName = "0.5.14" versionName = "0.5.15"
} }
buildTypes { buildTypes {
@@ -10,7 +10,7 @@ import ru.kalinamall.seaca.push.NotificationSoundResolver
class SeacaApplication : Application() { class SeacaApplication : Application() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
AppForegroundState.bind() AppForegroundState.bind(this)
val store = SessionStore(this) val store = SessionStore(this)
val settings = runBlocking { val settings = runBlocking {
NotificationSoundResolver.normalizeStoredSettings(this@SeacaApplication, store) NotificationSoundResolver.normalizeStoredSettings(this@SeacaApplication, store)
@@ -1,5 +1,6 @@
package ru.kalinamall.seaca.push package ru.kalinamall.seaca.push
import android.content.Context
import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ProcessLifecycleOwner import androidx.lifecycle.ProcessLifecycleOwner
@@ -9,11 +10,15 @@ object AppForegroundState {
@Volatile @Volatile
private var inForeground = false private var inForeground = false
fun bind() { private lateinit var appContext: Context
fun bind(context: Context) {
appContext = context.applicationContext
ProcessLifecycleOwner.get().lifecycle.addObserver( ProcessLifecycleOwner.get().lifecycle.addObserver(
object : DefaultLifecycleObserver { object : DefaultLifecycleObserver {
override fun onStart(owner: LifecycleOwner) { override fun onStart(owner: LifecycleOwner) {
inForeground = true inForeground = true
NotificationHelper.clearAll(appContext)
} }
override fun onStop(owner: LifecycleOwner) { override fun onStop(owner: LifecycleOwner) {
@@ -83,6 +83,10 @@ object NotificationHelper {
lockscreenVisibility = NotificationCompat.VISIBILITY_PRIVATE lockscreenVisibility = NotificationCompat.VISIBILITY_PRIVATE
} }
fun clearAll(context: Context) {
context.getSystemService(NotificationManager::class.java).cancelAll()
}
fun show( fun show(
context: Context, context: Context,
title: String, title: String,