We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Launch App from browser

I'm trying to launch my app in case it is installed and fallback to my website if tbe the app does not exist. (got some insights from  : http://stackoverflow.com/questions/13044805/how-to-check-if-an-app-is-installed-from-a-web-page-on-an-iphone

I was able to launch the app using custom url scheme , but was only able to so when there is user interaction (e.g. user clicks a button/link) :

     <a onclick="window.open('myapp://foo=bar', '_system')">Launch myapp</a>


However When using 

  window.open('myapp://foo=bar', '_system');

or 

 window.location = 'myapp://foo=bar'

without user interaction (e.g. on window load / document ready) the app does not launch.

Is this expected ?

Any workarounds ?

Thanks
Sagi

1 Reply

VK Vignesh Kumar D R Syncfusion Team May 17, 2016 01:01 PM UTC

Hi Sagi, 
Syncfusion Orubase is integrated with Cordova. So we can use cordova plugins also. 
Please install InAppbrowser initially and then proceed the following steps. 
1.       Open command line and navigate to application directory  
 cordova plugin add cordova-plugin-inappbrowser” 
 
Syntax for launching particular application: 
window.open('https://www.facebook.com', '_system'); 

We achieve this requirement using one of the following use cases.  
Use case 1: 
Here we use Mobile slider control. When the slider value will change above 50 means 'myapp://foo=bar' URL is loaded. Also initially set the below highlighted value is above 50, that particular URL will open when the page is loaded.  
<span> Change the Slider value: If the value above "50" means another url will open </span> 
    <div id="slider" data-role="ejmslider" data-ej-change="onChange" data-ej-value="50"></div> 
 
    <script> 
        function onChange(args) { 
            if (args.value > 50) 
                window.open('myapp://foo=bar','_system'); 
        } 
    </script> 
 
Use case 2: 
Here we use Mobile Button control. In the below code the button click event is triggered when document ready. So when the page is loaded, at the time click event triggered and that particular URL is opened. 
    <input id="button" type="button" data-role="ejmbutton" data-ej-text="Launch myapp" /> 
 
    <script> 
        $(function () { 
            $("#button").click(function () { 
                window.open('myapp://foo=bar','_system'); 
            }); 
            $("#button").trigger('click'); 
        }); 
    </script> 
 
Note: 
Please refer the below link for App availability ensuring 

Regards, 
Vignesh Kumar DR 


Loader.
Up arrow icon