Updated on 2026-08-14

This commit is contained in:
Tangem 2024-12-05 12:27:44 +05:00
parent b750588ef9
commit f1797da7ed
6 changed files with 34 additions and 5 deletions

View file

@ -118,6 +118,17 @@
android:scheme="tangem" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="onramp-success"
android:scheme="tangem" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View file

@ -2,13 +2,25 @@ package com.tangem.core.deeplink.global
import com.tangem.core.deeplink.DeepLink
class BuyCurrencyDeepLink(val onReceive: (txId: String) -> Unit) : DeepLink {
class BuyCurrencyDeepLink(
isOnrampFeatureEnabled: Boolean,
val onReceive: (txId: String) -> Unit,
) : DeepLink {
override val uri: String = "tangem://redirect?action=dismissBrowser"
override val uri: String = if (isOnrampFeatureEnabled) {
ONRAMP_REDIRECT_DEEPLINK
} else {
BUY_REDIRECT_DEEPLINK
}
override fun onReceive(params: Map<String, String>) {
onReceive(
params["txId"] ?: return,
params["merchant_transaction_id"] ?: return,
)
}
companion object {
const val ONRAMP_REDIRECT_DEEPLINK = "tangem://onramp-success?"
private const val BUY_REDIRECT_DEEPLINK = "tangem://redirect?action=dismissBrowser"
}
}

View file

@ -14,6 +14,7 @@ dependencies {
/** Core modules */
implementation(projects.core.datasource)
implementation(projects.core.utils)
implementation(projects.core.deepLinks.global)
/** Common modules */
implementation(projects.data.common)

View file

@ -2,6 +2,7 @@ package com.tangem.data.onramp
import com.squareup.moshi.Moshi
import com.tangem.blockchain.extensions.toBigDecimalOrDefault
import com.tangem.core.deeplink.global.BuyCurrencyDeepLink
import com.tangem.data.common.api.safeApiCall
import com.tangem.data.onramp.converters.CountryConverter
import com.tangem.data.onramp.converters.CurrencyConverter
@ -283,7 +284,7 @@ internal class DefaultOnrampRepository(
toDecimals = cryptoCurrency.decimals,
providerId = quote.provider.id,
toAddress = address,
redirectUrl = "tangem://redirect?action=dismissBrowser",
redirectUrl = BuyCurrencyDeepLink.ONRAMP_REDIRECT_DEEPLINK,
language = null,
theme = getTheme(),
requestId = requestId,

View file

@ -189,7 +189,10 @@ internal class TokenDetailsViewModel @Inject constructor(
deepLinksRegistry.registerWithViewModel(
viewModel = this,
deepLinks = listOf(
BuyCurrencyDeepLink(::onBuyCurrencyDeepLink),
BuyCurrencyDeepLink(
isOnrampFeatureEnabled = onrampFeatureToggles.isFeatureEnabled,
onReceive = ::onBuyCurrencyDeepLink,
),
),
)
userWallet = getUserWalletUseCase(userWalletId).getOrNull() ?: error("UserWallet not found")

View file

@ -65,6 +65,7 @@ internal class WalletDeepLinksHandler @Inject constructor(
if (onrampFeatureToggles.isFeatureEnabled || !userWallet.isMultiCurrency) {
add(
BuyCurrencyDeepLink(
isOnrampFeatureEnabled = onrampFeatureToggles.isFeatureEnabled,
onReceive = { txId ->
scope.launch { onBuyCurrencyDeepLink(txId, userWallet) }
},