2

I need to know is if I can, from an HTML web open an application that is installed on the mobile device. Is this possible? I could do with help of plugins can open installed applications from a single application, but from the browser?

I'm also working on Android and iOS with ionic framework

NHTorres
  • 1,488
  • 2
  • 19
  • 37

1 Answers1

3

I hope you're talking about the Ionic Framework hybrid mobile application.

It can be done easily using Cordova InAppBrowser plugin. Using this plugin you can execute external app or open link inside a browser if mentioned app don't exist.

You will want to do something like this:

    var scheme;

    // Don't forget to add the org.apache.cordova.device plugin!
    if(device.platform === 'iOS') {
        scheme = 'twitter://';
    }
    else if(device.platform === 'Android') {
        scheme = 'com.twitter.android';
    }

    appAvailability.check(
        scheme, // URI Scheme
        function() {  // Success callback
            window.open('twitter://user?screen_name=gajotres', '_system', 'location=no');
            console.log('Twitter is available');
        },
        function() {  // Error callback
            window.open('https://twitter.com/gajotres', '_system', 'location=no');
            console.log('Twitter is not available');
        }
    );

This example will try to execute Twitter app, if that app don't exist it will open twitter inside a child browser.

Needed Cordova plugins:

cordova plugin add com.lampa.startapp
cordova plugin add cordova-plugin-inappbrowser
cordova plugin add org.apache.cordova.device

Read more about it here: http://www.gajotres.net/how-to-launch-external-application-with-ionic-framework/

Gajotres
  • 57,163
  • 16
  • 99
  • 128
  • Oh, thank you very much for your answer, but what I need is to open in the browser installed on any device either Android or iOS application. – NHTorres Jul 28 '15 at 14:56
  • Have you even read about cordova-plugin-inappbrowser? This plugin is the browser. Unless you specifically want to open Chrome or Safari, but that changes nothing, you can still use cordova-plugin-inappbrowser to open Chrome or Safari. Just replace scheme variable content with appropriate app. Don't be lazy, no one here is going to write a code for you. – Gajotres Jul 28 '15 at 15:11