Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-13 13:06:39 +02:00
parent 35253cded5
commit 9ad4259a5c
4 changed files with 28 additions and 1 deletions

View file

@ -164,6 +164,9 @@ object PreferencesKeys {
// region Permission
fun getShouldShowPermission(permission: String) = booleanPreferencesKey("shouldShowPushPermission_$permission")
fun getShouldShowAskNotificationPermissionViaBs() =
booleanPreferencesKey("ShouldShowAskNotificationPermissionViaBs")
fun getShouldShowInitialPermissionScreen(permission: String) =
booleanPreferencesKey("shouldShowInitialPushPermissionScreen_$permission")
// endregion

View file

@ -2,6 +2,7 @@ package com.tangem.data.notifications
import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.preferences.PreferencesKeys
import com.tangem.datasource.local.preferences.PreferencesKeys.getShouldShowAskNotificationPermissionViaBs
import com.tangem.datasource.local.preferences.utils.*
import com.tangem.domain.notifications.repository.NotificationsRepository
import kotlinx.coroutines.flow.Flow
@ -73,4 +74,12 @@ class DefaultNotificationsRepository @Inject constructor(
)
}
}
override suspend fun shouldAskNotificationPermissionsViaBs(): Boolean {
return appPreferencesStore.getSyncOrDefault(getShouldShowAskNotificationPermissionViaBs(), false)
}
override suspend fun setShouldAskNotificationPermissionsViaBs(shouldAsk: Boolean) {
appPreferencesStore.store(key = getShouldShowAskNotificationPermissionViaBs(), value = shouldAsk)
}
}

View file

@ -56,4 +56,12 @@ interface NotificationsRepository {
suspend fun getWalletAutomaticallyEnabledList(): List<String>
suspend fun setNotificationsWasEnabledAutomatically(userWalletId: String)
/**
* By default it is false cause for the first try to show should be skipped. Only should be shown on second time
* app launch.
*/
suspend fun shouldAskNotificationPermissionsViaBs(): Boolean
suspend fun setShouldAskNotificationPermissionsViaBs(shouldAsk: Boolean)
}

View file

@ -236,6 +236,7 @@ internal class WalletModel @Inject constructor(
private fun subscribeOnPushNotificationsPermission() {
modelScope.launch {
val shouldAskNotificationPermissionsViaBs = notificationsRepository.shouldAskNotificationPermissionsViaBs()
val shouldShow = notificationsRepository.shouldShowSubscribeOnNotificationsAfterUpdate()
val isBiometricsEnabled = shouldSaveUserWalletsSyncUseCase()
val isHuaweiDevice = getIsHuaweiDeviceWithoutGoogleServicesUseCase()
@ -245,7 +246,13 @@ internal class WalletModel @Inject constructor(
"isHuaweiDevice $isHuaweiDevice",
)
if (!isBiometricsEnabled) return@launch
if (!shouldShow) return@launch
if (!shouldShow) {
return@launch
}
if (!shouldAskNotificationPermissionsViaBs) {
notificationsRepository.setShouldAskNotificationPermissionsViaBs(true)
return@launch
}
delay(timeMillis = 1_800)