Launching IOS and Android Applications from a browser link, Complete solution

Reading Time: 2 minutes

At work, while the developments of IOS and Android mobile apps were taking place, I was asked to show a small screen to mobile visitors in order for informing them that they can launch the application or install, you may simply see the situation below. The application is a J2EE application, but i do display a small screen to notify user about the mobile app depending on the device fetched.


Then initially I’ve designed and coded the backend and frontend to catch the mobile devices, and show a nice gui. Hereby I’ll be sharing the complete end-to-end solution. Let’s get started with how to implement a nice gui you observe in the above ¬†screen,

javascript to catch mobile devices:

	<script type="text/javascript">
		function iosDeviceLauncher() {
			document.location = 'macfit://';
					function() {
						document.location = '';
					}, 2500);

		var userAgent = navigator.userAgent.toLowerCase();
		var deviceIsAndorid = userAgent.match(/android/);
		var deviceIsIos = userAgent.match(/(iphone|ipod|ipad)/);
		if (deviceIsAndorid) {
		} else if (deviceIsIos) {


<div id="androidDeviceContent" style="display: none;"
			<img src="/images/macfit_mobile_logo.png" height="80px" width="80px"
				style="float: left;" />

			<div class="mobileAppContent">
				#{msg.template_macfit_title} <br /> #{msg.mobile_app_android_1}

			<div class="mobileAppLink">
		<div id="iosDeviceContent" style="display: none;" class="iosDevice">
			<img src="/images/macfit_mobile_logo.png" height="80px" width="80px"
				style="float: left;" />

			<div class="mobileAppContent">
				#{msg.template_macfit_title} <br /> #{msg.mobile_app_ios_1}

			<div class="mobileAppLink">
				<a href="#" onclick="iosDeviceLauncher()">#{msg.mobile_app_run_on_app}</a>

Android Part

    <action android:name="android.intent.action.VIEW"></action>
    <category android:name="android.intent.category.DEFAULT"></category>
    <category android:name="android.intent.category.BROWSABLE"></category>
    <data android:scheme="http" android:host=""></data>

The easiest part was android I would frankly say, so first of all when visitors tap on the launch the app or if it is not installed, it will forward the visitor to Google Play store to install the app easy peasy.

IOS Part

IOS was a challenging part for me I had to look for a possible solution, IOS itself for now as I conducted a long search, does not have any ability to run the app if installed, if not then open the application on the store to be installed. As you study the JQuery file I used a solution to launch the app, wait for 2500 ms for user action, if it falls then the visitor is forwarded to the Apple store in order for installing the application.



The Complete Tutorial on iOS/iPhone Custom URL Schemes