Tlaster / PreCompose

Compose Multiplatform Navigation && State Management

Home Page:https://tlaster.github.io/PreCompose/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Screen doesn't open when trying to navigate from a deep link

VladSavka opened this issue · comments

When app opened from deeplink then navigation to a related scene doesn't trigger. Instead it navigates to initialRoute

Code example:

...

  <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="http" />
                <data android:host="test.com" />
            </intent-filter>

....

scene(
           route = MainRouts.Profile.route,
           navTransition = NavTransition(),
           deepLinks = listOf("http://test.com/profile")
       ) {
           ProfileScreen()
       }

.....
Log from android studio's app links assistant:

Launching deeplink: http://test.com/profile.

$ adb shell setprop log.tag.AppIndexApi VERBOSE 

$ adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d 'http://test.com/profile' --splashscreen-show-icon 

Starting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=http://test.com/... }

Currently deeplink is not handling by default, you need to pass the intent data manually like this:

val navigator by lazy {
    Navigator()
}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
        App(
            navigator = navigator,
        )
    }
    intent.dataString?.let {
        navigator.navigate(it)
    }
}

ok, thank you for help!

close as inactive