PreCompose icon indicating copy to clipboard operation
PreCompose copied to clipboard

Deeplinks are not working

Open herveweb opened this issue 6 months ago • 5 comments

I've tried to setup deelinking using the deeplink field in the scene for my screen but it's not working for me.

Any chance I can please get a link to some documentation on how to set it up?

herveweb avatar Dec 29 '23 07:12 herveweb

Currently deeplink require manually handle on all platform, for example, in Android you can handle like this:

override fun onCreate(savedInstanceState: Bundle?) {
    //....
    intent.data?.let {
        navigator.navigate(it.toString())
    }
    addOnNewIntentListener {
        it?.data?.let {
            navigator.navigate(it.toString())
        }
    }
}

Tlaster avatar Dec 29 '23 09:12 Tlaster

I believe it's kinda confusing when you see a deepLinks field in the Scene method. It makes us think that it's readily available for all platforms. But I guess this might be coming in the future.

image

Unfortunately, for now I had to implement it separately on each platform. Thanks for the reply.

herveweb avatar Dec 30 '23 04:12 herveweb

Yes I agree, the keyword makes people confused, I'm still trying to implement deeplink handling automatically.

Tlaster avatar Jan 02 '24 06:01 Tlaster

Currently deeplink require manually handle on all platform, for example, in Android you can handle like this:

override fun onCreate(savedInstanceState: Bundle?) {
    //....
    intent.data?.let {
        navigator.navigate(it.toString())
    }
    addOnNewIntentListener {
        it?.data?.let {
            navigator.navigate(it.toString())
        }
    }
}

Hello, An for ios how do you do that ?

inveders avatar Apr 28 '24 05:04 inveders

Currently deeplink require manually handle on all platform, for example, in Android you can handle like this:

override fun onCreate(savedInstanceState: Bundle?) {
    //....
    intent.data?.let {
        navigator.navigate(it.toString())
    }
    addOnNewIntentListener {
        it?.data?.let {
            navigator.navigate(it.toString())
        }
    }
}

People copy-pasting this code, please be careful not to send the deep link event multiple times on activity re-creation. Thus:

  • You should read intent.data only once when savedInstanceState is null
  • If you call addOnNewIntentListener() from a Composable function, make sure you only call it once and not on each recomposition. I would recommend using DisposableEffect to also unregister the listener when it leaves the composition.

cbeyls avatar Apr 30 '24 12:04 cbeyls