Android M has added support for App links by creating a special assetlinks.json on the web server to delegate link handling to a mobile app.
For example, here's the content of such file:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.costingtons.app",
"sha256_cert_fingerprints": ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:"
"A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]
}
}]
Currently, the relation is defined as common.handle_all_urls which means any url will be routed to the app.
I would like the app to open specific routes, for example https://costingtons.com/products/a-product would open in the app but https://costingtons.com would open the web version.
Apple Universal Links similar configuration file can define paths to be opened in the app, and the syntax supports pattern matching like /products/* etc.
Is there any way to do something like that with App Links in Android ?
The assetlinks.json file specifies that that particular app is allowed to open all URLs, but the app itself (via the intent filter in its AndroidManifest) can be more restrictive so that it only opens the product links, and not the general website link.
Furthermore even if the intent filter is invoked for a particular URL, the receiver can still decide not to handle it, leaving it to the next handler (often the browser). (Maybe you want the app to handle links when on cellular, but let the browser handle them when on wifi).