How to launch any mobile app from the web

Ian Spryn
Level Up Coding
Published in
6 min readDec 29, 2021

--

I was recently tasked at my job with learning if it was possible to launch an app that our company did not own on both iOS and Android. The short answer, with a little digging, is yes! It’s important to note that this method is different than deep-linking into the application. This technique will allow you to simply launch the application and nothing more.

For this article, we’ll try to launch the Google Home app.

iOS

Let’s find the URL Scheme for the Google Home app.

This method requires access to a physical iOS device.

Start with downloading iMazing on your Mac. This tool allows you to manage all kinds of content on your iOS device, but most importantly, it will allow us to extract the IPA of our desired app. You do not need to pay for the premium version of iMazing.

Launch iMazing and plug in your device.

Select “Manage Apps.” You may need to enter your Apple ID password. Furthermore, it may take several minutes for the list of apps to load.

After your apps have loaded, do the following:

  1. Select “Library” on the top
  2. Search for Google Home or your desired app, or click “Add from App Store” if you don’t have the app on your device. You can only add apps that you have already acquired with your current Apple ID.
  3. Click the download icon

When it has finished downloading, right-click the application, select “Export .IPA,” and save it in your desired folder.

Now, it’s time to extract the URL scheme.

First, take your downloaded .ipa file and rename its filetype to .zip

Double-click it to unzip it, and then navigate to the .app file.

Right-click it and select “Show Package Contents.”

Once it opens, you’ll see a Info.plist file. Open that in your editor of choice. Look for entries under the array of CFBundleURLSchemes.

Info.plist

It looks like there are quite a few to pick from here. For this article, we’ll use googlehome. But for what it’s worth, any of these will work if used.

Android

For Android, we need two things in order to launch the app:

  1. The Application ID
  2. The Application Scheme and its associated host

The Application ID is very easy to find. Just head on over to the Play Store in your browser and find the application.

I highlighted the Application ID in the screenshot’s address bar above.

The Application Scheme is a little more tricky, but still quite doable.

There are many ways to acquire the APK of an Android app. You can look for tutorials, but I’ll share how I like to do it. I like to use either APKMirror or APK Pure. Sometimes one website has the APK while the other doesn’t.

You can also pull the APK from your device using ADB. Read more from this Stackoverflow post.

Once you’ve acquired your APK, head on over to APKTool and follow the installation instructions for your platform. This tool will allow you to decompile the application so that we may extract the information we need.

Once you followed those instructions, apktool should work in your terminal.

Run the following command:

apktool d path/to/your/app.apk

A new folder will appear in your directory that contains the extracted content. Inside of it, you will find the AndroidManifest.xml file. Search within the file for android:scheme=. You might find multiple results.

AndroidManifest.xml

What we need is the correct android:host and android:scheme, but how do we figure out which one to pick? Sometimes there are several to choose from. In this case, there are dozens.

The short answer is trial and error. But we can narrow our scope a little with a little digging.

Look at the <activity> or <activity-alias> tag that is a parent to a given <intent-filter> tag. Look at the android:name attribute. Here’s the two that come from the XML file:

<activity ... android:name=”com.google.android.apps.chromecast.app.deeplink.DeeplinkActivity” ...>...<activity-alias ... android:name=”com.google.android.apps.chromecast.app.DiscoveryActivity” ...>

DeeplinkingActivity might be useful if we want to deeplink into a specific component of the app, but that’s for another article. DiscoveryActivity, on the other hand, sounds interesting, as it sounds like it could be the home page of the application. Sure enough, if we look inside, we find one entry that contains a host equal to chromecast.comand a scheme equal to comgooglecast. Great! We now have everything we need to launch the Android app.

Writing the JavaScript

Many articles exist that show how to determine if the user is on an iOS or Android device. This article doesn’t focus on that, so we’ll have two buttons, each that launch the application.

<button onclick="launchAppOnAppleDevice()">iOS Device</button>
<button onclick="launchAppOnAndroidDevice()">Android Device</button>

iOS is the easiest of the two platforms to set up.

function launchAppOnAppleDevice() {
const url = "googlehome://";
window.location.replace(url);
}

That’s it!

Launching on iOS

If the app isn’t installed on the device, Safari will show a popup with an error. In my experience, it’s been very hard to find a reliable way to navigate the user to the App Store if it failed to launch the app.

Launching on iOS without the app installed

Android is a little more tricky to set up, but if you don’t want to understand the nitty-gritty details, it’ll be just a quick copy-and-paste for you.

Android uses something called Intents. You must encode your link in a special way in order to successfully launch the app. If you’d like to understand more about it, see more at Android Intents with Chrome.

Your intent URL is going to look something like the following:

intent://ANDROID_HOST/#Intent;scheme=ANDROID_SCHEME;package=APP_PACKAGE;end

For the Google Home app,

  • ANDROID_HOST = chromecast.com
  • ANDROID_SCHEME = comgooglecast
  • APP_PACKAGE = com.google.android.apps.chromecast.app
function launchAppOnAndroidDevice() {
const url = "intent://chromecast.com/#Intent;scheme=comgooglecast;package=com.google.android.apps.chromecast.app;end";
window.location.replace(url);
}

Here’s an important note. If you notice when you tap the Android button it takes you to the Play Store despite you having the app installed, then double-check your ANDROID_HOST and ANDROID_SCHEME values, or try other ones from the AndroidManifest.xml file.

Congratulations! You can now launch any app on either platform.

Launching on Android

If the app isn’t installed on the device, Android will politely take you to the Play Store without any additional legwork, which, in my opinion, is a big win over Apple’s methodology which simply pops up an alert dialog with no easy and reliable way to detect that it failed.

Launching on Android without the app installed

--

--

25 years. Software Engineer 👨‍💻 Designer 💡 and photographer 📷