fix: clear SAC push notifications when app is opened (0.5.15)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user