Search code examples
androidapplinks

How would you implement routing within an Activity for AppLinks?


So the applinks documentation states that you should specify your app's package name through the al:android:package property, and the consuming application should launch an Intent to start your app. What I feel is lacking from the documentation is a suggestion or specification on how to provide custom parameters or routing info with that Intent. It's not deep linking unless you specify some depth!

It does specify how to provide Extras through the use of the al_applink_data structure. It does not however say how the target application should provide metadata for the client to consume and send with that structure.

The only suggestion I can think of is to provide the metadata through the optional al:android:url-parameter. So for instance if I'm running a blog, I would provide the URL com.myblog://123, "123" being the ID to a blog entry.

I don't feel like this is an optimal solution. I would then have to parse the URL in order to get the argument. I feel a better solution would be to have a an applink-property named something like al:android:extras where I could give key-value pairs to consume directly. Why is it not implemented this way?

Am I doing it right if I implement metadata-passing the way I described? Is there something I'm missing with regards to the applinks spec?


Solution

  • The original http(s) url is given to you inside al_applink_data under the target_url key, so you can certainly pass metadata that way.

    Passing it via the optional al:android:url is also OK.

    Lastly, if you have cooperation from the calling app, they can certainly pass data to you via the extras blob.

    The reason there's no al:android:extras is that app links was designed to be a routing protocol, and not describe semantics for your app.