Skip to content

Commit 13d3b3c

Browse files
authored
Merge pull request #567 from code-payments/chore/support-deeplink-jump
chore: support deeplink jumping
2 parents dfaeba9 + 7ffaf53 commit 13d3b3c

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<category android:name="android.intent.category.BROWSABLE" />
111111

112112
<data
113-
android:host="cash.getcode.com"
113+
android:host="@string/root_url_cash_no_protocol"
114114
android:pathPattern="/cash/.*"
115115
android:scheme="https" />
116116
</intent-filter>
@@ -127,6 +127,18 @@
127127
android:pathPattern="/c/.*"
128128
android:scheme="https" />
129129
</intent-filter>
130+
131+
<intent-filter>
132+
<action android:name="android.intent.action.VIEW" />
133+
134+
<category android:name="android.intent.category.DEFAULT" />
135+
<category android:name="android.intent.category.BROWSABLE" />
136+
137+
<data
138+
android:host="jump.getcode.com"
139+
android:scheme="https" />
140+
</intent-filter>
141+
130142
<intent-filter>
131143
<action android:name="android.intent.action.VIEW" />
132144

app/src/main/java/com/getcode/util/DeeplinkHandler.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.net.Uri
66
import android.os.Parcelable
77
import androidx.core.net.toUri
88
import cafe.adriel.voyager.core.screen.Screen
9+
import com.getcode.R
910
import com.getcode.model.PrefsBool
1011
import com.getcode.models.DeepLinkRequest
1112
import com.getcode.navigation.screens.ScanScreen
@@ -55,7 +56,7 @@ class DeeplinkHandler @Inject constructor(
5556

5657
suspend fun handle(intent: Intent? = debounceIntent): DeeplinkResult? {
5758
println(intent)
58-
val uri = when {
59+
var uri = when {
5960
intent?.data != null -> intent.data
6061
intent?.getStringExtra(Intent.EXTRA_TEXT) != null -> {
6162
val sharedLink = intent.getStringExtra(Intent.EXTRA_TEXT)?.toUri() ?: return null
@@ -68,6 +69,14 @@ class DeeplinkHandler @Inject constructor(
6869
else -> null
6970
} ?: return null
7071

72+
// check for jump
73+
if (uri.host == context.getString(R.string.root_url_jump_no_protocol)) {
74+
val source = uri.getQueryParameter("source")
75+
if (source != null) {
76+
uri = Uri.parse(source)
77+
}
78+
}
79+
7180
return when (val type = uri.deeplinkType) {
7281
is Type.Login -> {
7382
DeeplinkResult(

app/src/main/res/values/strings-universal.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<string translatable="false" name="root_url_cash">https://cash.getcode.com</string>
1010
<string translatable="false" name="app_url_cash">codewallet://cash.getcode.com</string>
1111
<string translatable="false" name="root_url_app_no_protocol">app.getcode.com</string>
12+
<string translatable="false" name="root_url_jump_no_protocol">jump.getcode.com</string>
1213
<string translatable="false" name="root_url_cash_no_protocol">cash.getcode.com</string>
1314
<string translatable="false" name="root_url_sdk_no_protocol">sdk.getcode.com</string>
1415
<string translatable="false" name="root_url_tipcard_no_protocol">tipcard.getcode.com</string>

0 commit comments

Comments
 (0)