Skip to content

Commit

Permalink
Handle "register mini app" deeplink
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Aug 16, 2024
1 parent d9d1b85 commit 6bd8cca
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
compileSdk compile_sdk_version
minSdkVersion min_sdk_version
targetSdkVersion compile_sdk_version
versionCode 112
versionName "0.39.2"
versionCode 113
versionName "0.39.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

ksp {
Expand Down
72 changes: 72 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="${applicationId}.DarkLauncherAlias"
Expand All @@ -116,6 +124,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="${applicationId}.MonoLauncherAlias"
Expand All @@ -140,6 +156,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="${applicationId}.LeoLauncherAlias"
Expand All @@ -164,6 +188,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="${applicationId}.MustangLauncherAlias"
Expand All @@ -188,6 +220,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="${applicationId}.YakLauncherAlias"
Expand All @@ -212,6 +252,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="${applicationId}.PunkLauncherAlias"
Expand All @@ -236,6 +284,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="${applicationId}.ApeLauncherAlias"
Expand All @@ -260,6 +316,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="${applicationId}.Ball8LauncherAlias"
Expand All @@ -284,6 +348,14 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/DeeplinkScheme" />
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="unstoppable.money" />
<data android:pathPrefix="/referral" />
</intent-filter>
</activity-alias>
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.horizontalsystems.bankwallet.core.adapters.zcash.ZcashAdapter
import io.horizontalsystems.bankwallet.core.managers.ActiveAccountState
import io.horizontalsystems.bankwallet.core.managers.Bep2TokenInfoService
import io.horizontalsystems.bankwallet.core.managers.EvmKitWrapper
import io.horizontalsystems.bankwallet.core.managers.MiniAppRegisterService.RegisterAppResponse
import io.horizontalsystems.bankwallet.core.providers.FeeRates
import io.horizontalsystems.bankwallet.core.utils.AddressUriResult
import io.horizontalsystems.bankwallet.entities.Account
Expand Down Expand Up @@ -214,6 +215,7 @@ interface INetworkManager {
fun ping(host: String, url: String, isSafeCall: Boolean): Flowable<Any>
fun getEvmInfo(host: String, path: String): Single<JsonObject>
suspend fun getBep2Tokens(): List<Bep2TokenInfoService.Bep2Token>
suspend fun registerApp(userId: String, referralCode: String): RegisterAppResponse
}

interface IClipboardManager {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class NetworkManager : INetworkManager {
override suspend fun getBep2Tokens(): List<Bep2TokenInfoService.Bep2Token> {
return Bep2TokenInfoService.service().tokens()
}

override suspend fun registerApp(userId: String, referralCode: String)
: MiniAppRegisterService.RegisterAppResponse {
return MiniAppRegisterService.service().registerApp(userId, referralCode)
}
}

object ServiceFullTransaction {
Expand Down Expand Up @@ -145,6 +150,28 @@ object ServiceChangeLogs {
}
}

object MiniAppRegisterService {
private val apiUrl = "https://be.unstoppable.money/"

fun service(): UnstoppableApi {
return APIClient.retrofit(apiUrl, 60)
.create(UnstoppableApi::class.java)
}

interface UnstoppableApi {
@GET("api/v1/tasks/registerApp")
suspend fun registerApp(
@Query("userId") userId: String,
@Query("referralCode") referralCode: String
): RegisterAppResponse
}

data class RegisterAppResponse(
val success: Boolean,
val message: String
)
}

object APIClient {

private val logger = HttpLoggingInterceptor().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object MainModule {
App.localStorage,
App.wcSessionManager,
App.wcManager,
App.networkManager,
) as T
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.horizontalsystems.bankwallet.modules.main

import android.net.Uri
import android.util.Log
import androidx.lifecycle.viewModelScope
import cash.z.ecc.android.sdk.ext.collectWith
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.IAccountManager
import io.horizontalsystems.bankwallet.core.IBackupManager
import io.horizontalsystems.bankwallet.core.ILocalStorage
import io.horizontalsystems.bankwallet.core.INetworkManager
import io.horizontalsystems.bankwallet.core.IRateAppManager
import io.horizontalsystems.bankwallet.core.ITermsManager
import io.horizontalsystems.bankwallet.core.ViewModelUiState
Expand Down Expand Up @@ -41,6 +43,7 @@ class MainViewModel(
private val localStorage: ILocalStorage,
wcSessionManager: WCSessionManager,
private val wcManager: WCManager,
private val networkManager: INetworkManager
) : ViewModelUiState<MainModule.UiState>() {

private var wcPendingRequestsCount = 0
Expand Down Expand Up @@ -320,11 +323,34 @@ class MainViewModel(
}
}

deeplinkString.startsWith("https://unstoppable.money/referral") -> {
val userId: String? = deepLink.getQueryParameter("userId")
val referralCode: String? = deepLink.getQueryParameter("referralCode")
if (userId != null && referralCode != null) {
registerApp(userId, referralCode)
}
}

else -> {}
}
return Pair(tab, deeplinkPage)
}

private fun registerApp(userId: String, referralCode: String) {
viewModelScope.launch {
try {
val response = networkManager.registerApp(userId, referralCode)
if (response.success) {
//do nothing
} else {
Log.e("MainViewModel", "registerApp api fail message: ${response.message}")
}
} catch (e: Exception) {
Log.e("MainViewModel", "registerApp error: ", e)
}
}
}

private fun syncNavigation() {
mainNavItems = navigationItems()
if (selectedTabIndex >= mainNavItems.size) {
Expand Down

0 comments on commit 6bd8cca

Please sign in to comment.