Urgent.News

What's breaking now, across thousands of outlets.

Tech

Opening the app from a link, and what happens when it is not installed

A link on the web should open the app on the exact screen that the link points to. Sometimes the app is not installed. In that case the link should do something better than showing the person a page that only says the app exists. The second part is the hard one. The browser will not tell you whether an app is installed, and it should not: a page that could list your installed apps would be a…

When a link is used to open an app and the app is not installed, the browser should ideally present a better result than just showing a message stating that the app exists. However, the browser cannot determine if an app is installed, and revealing this information would essentially act as a fingerprinting tool. An example of this situation in production can be seen when accessing Pavel Durov's channel in the Nicegram catalogue via a link.

If the app is installed, the phone will open the Nicegram app. If it is not installed, the link will open the channel on the web and carry the original link, allowing the user to access the channel through the web browser.

Initially, the page tried to determine whether the app was installed by itself, using a custom URL scheme and a timer. If the app took the navigation, the browser would suspend the page, and the timer would run late without executing any code. If the app did not take the navigation within a certain timeframe, the code would assume there was no app installed and redirect the user to the store page.

The timer was set to 25 milliseconds, and if the time exceeded 100 milliseconds, the code would assume there was no app installed. However, this is not always accurate, as a busy phone may take more than 100 milliseconds to switch between apps, causing the timer to incorrectly assume there is no app installed.

Developers attempted to address this issue by using universal links or App Links on iOS and Android, which allow the app to claim specific URLs from the domain at installation. The platform then takes control in deciding whether to open the app or the website. A single path claim on the website, rather than the entire domain, is recommended to avoid confusion and ensure a smooth user experience.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 14 October →