Search This Blog

Saturday 20 February 2016

Opening other apps from your using cordova


  • Cordova uses UrlSchemes to open other apps.
  • URL schemes for ios and android will be different,

ex: for opening skype(lync), urlscheme for
           ios: lync:// or sip://
           android: com.microsoft.office.lync15

additionally to know the UrlScheme of an app for android you can look at the url of the app in google play store.
ex: https://play.google.com/store/apps/details?id=com.microsoft.office.lync15&hl=en

URL Schemes for some popular apps
ios android
sip:// or lync:// com.microsoft.office.lync15
yammer:// com.yammer.v1
twitter:// com.twitter.android
ms-outlook:// com.microsoft.office.outlook

for opening these apps, we have a good plugin called lampa: https://github.com/lampaa/com.lampa.startapp

to install the plugin use,
ionic plugin add com.lampa.startapp

to use the plugin use the following code:

if(device.platform === 'iOS') 
{
scheme = 'lync://';
}
else if(device.platform === 'Android')
{
scheme = 'com.microsoft.office.lync15';
}
navigator.startApp.start(scheme,function() { 
//alert("found 2013");
},
function() {  
$ionicPopup.alert({       
 template: "Please Install Lync",
 okType:'button-positive'
});
});

you can also do app availability check using it:
navigator.startApp.check("com.application.name", function(message) { /* success */
    console.log("app exists: "); 
    console.log(message.versionName); 
    console.log(message.packageName); 
    console.log(message.versionCode); 
    console.log(message.applicationInfo); 
}, 
function(error) { /* error */
    console.log(error);
});

additional details can be found in the github page.

additionally,
to allow other apps to open your app, you can define custom url scheme for your app:

ionic plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=mycoolapp

mycoolapp:// is the url scheme of your app for ios.
if you want to do it manually, open xcodeproj file and add string URL Identifier in info.plist.
ex:


more details at: https://github.com/EddyVerbruggen/Custom-URL-scheme

for android:
add scheme in data node under activity->intent-filter.
<activity ....>
     <intent-filter>
         <action android:name="android.intent.action.VIEW" />
         <category android:name="android.intent.category.DEFAULT" />
         <category android:name="android.intent.category.BROWSABLE" />
         <data android:scheme="myapp" />
     </intent-filter>
 </activity>

reference: http://www.telerik.com/blogs/how-to-use-custom-url-schemes

please comment if you have any queries/inputs.

1 comment:

  1. Casino-Based Blackjack Online - CasinoTaratDos
    This gambling site bet365 실시간 배당 흐름 offers to be a blackjack game, 룰렛 배당 to 넥스트 벳 have fun! Players 도박 사이트 can also play the 사다리사이트 classic game of casino blackjack, as the casino has

    ReplyDelete