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"
minSdk = 26
targetSdk = 35
versionCode = 28
versionName = "0.5.14"
versionCode = 29
versionName = "0.5.15"
}
buildTypes {
@@ -10,7 +10,7 @@ import ru.kalinamall.seaca.push.NotificationSoundResolver
class SeacaApplication : Application() {
override fun onCreate() {
super.onCreate()
AppForegroundState.bind()
AppForegroundState.bind(this)
val store = SessionStore(this)
val settings = runBlocking {
NotificationSoundResolver.normalizeStoredSettings(this@SeacaApplication, store)
@@ -1,5 +1,6 @@
package ru.kalinamall.seaca.push
import android.content.Context
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ProcessLifecycleOwner
@@ -9,11 +10,15 @@ object AppForegroundState {
@Volatile
private var inForeground = false
fun bind() {
private lateinit var appContext: Context
fun bind(context: Context) {
appContext = context.applicationContext
ProcessLifecycleOwner.get().lifecycle.addObserver(
object : DefaultLifecycleObserver {
override fun onStart(owner: LifecycleOwner) {
inForeground = true
NotificationHelper.clearAll(appContext)
}
override fun onStop(owner: LifecycleOwner) {
@@ -83,6 +83,10 @@ object NotificationHelper {
lockscreenVisibility = NotificationCompat.VISIBILITY_PRIVATE
}
fun clearAll(context: Context) {
context.getSystemService(NotificationManager::class.java).cancelAll()
}
fun show(
context: Context,
title: String,