This Post is being built#
By using deep links, you can jump from the notifications to a certain routes in NavGraph or even Nested Graph
Prerequisites#
- KotlinX.Serialization
- Navigation Compose
- Navigating Deep Links with Intents
Url Parameters#

Using Something#
The following DetailPage class is used as an example for the navigation
@Serializable
data class DetailPage(
@SerialName("title_name")
val title: String,
@SerialName("sub_title")
val subTitle: String? = null
val id: Int,
)
If you want the
navDeepLinkto parse your URI, you should put it in this format
appName://DetailPage/{title_name}/{id}?sub_title={sub_title}
In the compose navigation the code will look like
composable<DetailPage>(
deepLinks = listOf<DetailPage>(
basePath = "appName://DetailPage",
)
)
What if the Uri is in different format?#
For example, you want to extract the id and name pattern from the uri or using custom uri altogether. together, you might want to write a custom uriPattern in the NavDeepLink.navDeepLink API
It can be put together as
composable<DetailPage>(
deepLinks = listOf<DetailPage>(
basePath = "appName://DetailPage",
) {
uriPattern = "appName://{id}_{title_name}?sub_title={sub_title}"
}
) {
val args = it.toRoute<DetailPage>
}
Then args can be retrieve using
| |
[!NOTE] This uriPattern might not be type safe, but it offers flexibility for those in need