NHTorres
NHTorres

Reputation: 1538

Open installed application from the browser

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

Upvotes: 2

Views: 9319

Answers (1)

Gajotres
Gajotres

Reputation: 57309

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/

Upvotes: 3

Related Questions