Chrome Intents

What are Chrome intents?

Chrome intents are a set of structured APIs within the Chrome browser that allow users to open apps and perform specific actions directly within the web browser. For example, a music streaming app could use a Chrome intent to play a specific track in the Chrome browser, eliminating the need for a standalone player.

Chrome intents are the deep linking replacement for URI schemes on the Android device within the Chrome browser. Instead of assigning window.location or an iframe.src to the URI scheme, in Chrome, you’ll need to use their intent string. While it adds complexity, the Chrome intent is actually a powerful tool since it automatically handles the case of the mobile app not being installed.

Here’s the redirect logic baked into the Chrome intent:

    • Open app via URI scheme, if installed
    • Fall back to Play Store page, if not installed
    • [Optional] Specify a URL to fall back to instead of Play Store, if not installed

This means that if you use the Chrome intent, you do not need to handle the case of the app not being installed like you do with the URI scheme.

Configuring Chrome intents

Configuring your app for a Chrome intent is the same as configuring for a URI scheme, since Chrome uses it under the hood. You need to pick an Activity within your app that you’d like to open when the URI scheme is triggered and register an intent filter for it. Add the following code within the tag within your manifest that corresponds to the Activity you want to open.

You can change your_uri_scheme to the URI scheme that you’d like. Ideally, you want this to be unique. If it overlaps with another app’s URI scheme, the user will see an Android chooser when clicking on the link. You see this often when you have multiple browsers installed, as they all register for the HTTP URI.

Practical use

In Chrome, you cannot use the basic URI scheme to open up the app. Instead, you will need to issue the formatted Chrome intent string. Here’s an example Chrome intent structure:

‘intent://path#Intent;scheme=URI Scheme;package=package name;S.browser_fallback_url=fallback url

Here are the variables you can use for the string:

      • URI scheme [required]: This is the scheme that was configured in the previous example. (e.g., Pinterest)
      • App package name [required]: This is the package name of the app, as configured for the project.
      • URI path [optional]: This is an optional string to add which allows you to customize the path. For example, let’s say you wanted to route to pinterest://cats/1234. ‘cats/1234’ would be the URI path. You could then insert ‘cats/1234’ into the path section of the intent string. If not, leave empty.
      • Fallback URL [optional]: This is an optional field where you can specify a URL encoded website URL to fallback to if the app is not installed. The default option if not specified is to open the Play Store app page. If you don’t use this variable, just remove the whole ‘S.browser_fallback_url=’ part of the intent string.

Learn more in our Technical Guide to Android Chrome Intents.