5

My app is under Ionic 4 for android and I have to open/run/launch external app (for exemple com.google.android.youtube or com.sygic.truck) -> for instance, any installed app.

I tested many options without any success :

InAppBrowserModule (using application://my.package.name).

Cordova plugin lampaa (I didn't find any ways to use it under angular/ts app type).

I tried also webIntent using package option and action option calling the main Activity.


For InAppBrowserModule, i'm stuck with the http:// protocole appended before my app url.

For Lampaa, i'm stuck with the undefined startApp (even after following other threads suggestions).

And for webIntent, I don't think that it's relevent for my issue.

Any suggestions ?

Thanks in advance !


[EDIT]

I finally make it works !

You can use one of those 2 lines :

 this.iab.create('android-app://com.google.android.youtube',"_system"); window.open('android-app://com.google.android.youtube',"_system"); 

You can replace com.google.android.youtube by any application package name !

2
  • Works well in the ionic / cordova app, but in the Web Browser (PWA) it goes directly to the Play store. Where are the docs about this "android-app" scheme? I searched but I can't find. Commented May 6, 2020 at 21:25
  • Works very well but is that also working for ios? Commented Jun 16, 2021 at 19:06

3 Answers 3

5

You can check if the user is on Android, have the app installed and later open it as follow:

constructor( private platform: Platform, // from 'ionic-angular' private appAvailability: AppAvailability, // from '@ionic-native/app-availability' private iab: InAppBrowser, // from '@ionic-native/in-app-browser' ) {} openYoutube() { const package = "com.google.android.youtube" if(this.platform.is('android')) { this.appAvailability.check(package) .then(()=> { this.iab.create('android-app://'+package, '_system', 'location=yes') }) .catch(()=> { // not installed ) } else { // not on Android } } 
Sign up to request clarification or add additional context in comments.

Comments

1

For ionic 4 we can use

ionic cordova plugin add cordova-plugin-app-launcher npm install @ionic-native/app-launcher 

2 Comments

can you add a video code param to open youtube with the video ?
It doesn't start the app. It just checks whether app can launch?
1

You can use the following cordova plugin to check if other apps are installed and launch them.

ionic cordova plugin add cordova-plugin-app-launcher

npm install @ionic-native/app-launcher

Simple Cordova plugin to see if other apps are installed and launch them.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.