airbnb / DeepLinkDispatch

A simple, annotation-based library for making deep link handling better on Android
http://nerds.airbnb.com/deeplinkdispatch/
4.37k stars 407 forks source link

How to map one link to another? #263

Open Ghedeon opened 4 years ago

Ghedeon commented 4 years ago

Let say there are multiple external links that resolve to the same app link. Ex: www.foo.com/home -> app://home www.foo.com/dashboard -> app://home

Yes, we can list them all in @DeepLink annotation but in case we have some Uri pattern matching logic in the activity, we'd need to parse all of them. It would be much easier to just rethrow the app link, so it becomes a single source of truth, without www.foo.com/home even hitting the activity. Is there elegant way to declare such mapping? So far I can only think of custom handling in DeepLinkActivity.

Ghedeon commented 4 years ago

This seems to be working:

    @JvmStatic
    @DeepLink("www.foo.com/home")
    fun messagesIntent(context: Context, extras: Bundle): Intent {
        extras.putString(DeepLink.URI, "app://home")
        return homeIntent(context)
    }

Is that ok to override DeepLink.URI like this?