From 9ad4259a5c21e3d75c16ac99ebf15081e970db5c Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 13 Oct 2025 13:06:39 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../datasource/local/preferences/PreferencesKeys.kt | 3 +++ .../data/notifications/DefaultNotificationsRepository.kt | 9 +++++++++ .../notifications/repository/NotificationsRepository.kt | 8 ++++++++ .../feature/wallet/child/wallet/model/WalletModel.kt | 9 ++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt index 90230d2f23..a91cb3cf09 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt @@ -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 diff --git a/data/notifications/src/main/java/com/tangem/data/notifications/DefaultNotificationsRepository.kt b/data/notifications/src/main/java/com/tangem/data/notifications/DefaultNotificationsRepository.kt index 5795eed9b7..d8dd3053d7 100644 --- a/data/notifications/src/main/java/com/tangem/data/notifications/DefaultNotificationsRepository.kt +++ b/data/notifications/src/main/java/com/tangem/data/notifications/DefaultNotificationsRepository.kt @@ -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) + } } \ No newline at end of file diff --git a/domain/notifications/src/main/java/com/tangem/domain/notifications/repository/NotificationsRepository.kt b/domain/notifications/src/main/java/com/tangem/domain/notifications/repository/NotificationsRepository.kt index 00d20b0f04..887576ef52 100644 --- a/domain/notifications/src/main/java/com/tangem/domain/notifications/repository/NotificationsRepository.kt +++ b/domain/notifications/src/main/java/com/tangem/domain/notifications/repository/NotificationsRepository.kt @@ -56,4 +56,12 @@ interface NotificationsRepository { suspend fun getWalletAutomaticallyEnabledList(): List 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) } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index 639d9da483..84cea60e9f 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -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)