[ad_1]
I’m trying to get the code
from GitHub Oauth API playground://gh?code=XYZ
in the ViewModel through savedStateHandler
. My composable screen configuration:
NavGraphBuilder.composable(
route = "login",
deepLinks = listOf(navDeepLink {
uriPattern = "playground://gh?code={code}"
})
) {
Log.d("MyLog", it.arguments?.getString("code", "nothing") ?: "null")
//...
}
MyLog
is always nothing
I also tried to implement the NavGraphBuilder.composable.attributes
parameter, but the result was the same.
I’m just getting familiar with Compose and went through the Google Code labs. https://developer.android.com/codelabs/jetpack-compose-navigation#4 – this worked as expected, but the issue is the argument is required.
I also have a WebViewScreen composable that needs a URL and that works.
builder.composable(
route = "browser",
arguments = listOf(
navArgument("url") {
type = NavType.StringType
}
),
deepLinks = listOf(
navDeepLink {
uriPattern = "playground://gh/browser/{url}"
}
)
) {
//...
}
Not sure if this can be achieved with Jetpack Compose Navigation or do I have to use the Intent
approach a pass it to the ViewModel
?
[ad_2]