Skip to content

Commit 28c7b25

Browse files
committed
resolving query params in deep links into the app since it's not supported as a path in the manifest declaration
1 parent 849c77a commit 28c7b25

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

Simplenote/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787
<data
8888
android:host="app.simplenote.com"
89-
android:pathPattern="/account/.*/reset?redirect=simplenote://launch"
89+
android:pathPattern="/account/.*/reset"
9090
android:scheme="https">
9191
</data>
9292

@@ -122,7 +122,7 @@
122122
<category android:name="android.intent.category.DEFAULT" />
123123
<data
124124
android:host="app.simplenote.com"
125-
android:pathPattern="/account/.*/reset?redirect=simplenote://launch"
125+
android:pathPattern="/account/.*/reset"
126126
android:scheme="https">
127127
</data>
128128
</intent-filter>

Simplenote/src/main/java/com/automattic/simplenote/DeepLinkActivity.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ class DeepLinkActivity : AppCompatActivity() {
2727
startActivity(intent)
2828
}
2929
VERIFIED_WEB_SCHEME -> {
30-
// New MagicLink
31-
startMagicLinkConfirmation(uri)
30+
// Check if this is a password reset URL
31+
if (uri.path?.contains("/account/") == true && uri.path?.contains("/reset") == true) {
32+
handlePasswordReset(uri)
33+
} else {
34+
// New MagicLink
35+
startMagicLinkConfirmation(uri)
36+
}
3237
}
3338
LOGIN_SCHEME -> {
3439
if (queryParamContainsData(uri.query, USERNAME_KEY_QUERY) && queryParamContainsData(uri.query, AUTH_CODE_QUERY)) {
@@ -88,6 +93,21 @@ class DeepLinkActivity : AppCompatActivity() {
8893
}
8994
}
9095

96+
private fun handlePasswordReset(uri: Uri) {
97+
val redirectParam = uri.getQueryParameter("redirect")
98+
if (redirectParam == "simplenote://launch") {
99+
// Handle the redirect to launch the app
100+
val intent = IntentUtils.maybeAliasedIntent(applicationContext)
101+
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
102+
startActivity(intent)
103+
} else {
104+
// Default behavior for reset URLs without redirect
105+
val intent = IntentUtils.maybeAliasedIntent(applicationContext)
106+
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
107+
startActivity(intent)
108+
}
109+
}
110+
91111
private fun queryParamContainsData(path: String?, otherString: String) : Boolean = path?.contains(otherString, true) == true
92112

93113

0 commit comments

Comments
 (0)