ionic 5 open another application

 import { Component } from '@angular/core';

import { AppLauncher, AppLauncherOptions } from '@ionic-native/app-launcher/ngx';

import { Platform } from '@ionic/angular';


@Component({

  selector: 'app-tab3',

  templateUrl: 'tab3.page.html',

  styleUrls: ['tab3.page.scss']

})

export class Tab3Page {

 

  

  constructor(private appLauncher: AppLauncher,

    private platform: Platform) { }

  open() {

    const options: AppLauncherOptions = {

      packageName:"com.instagram.android"

    }

    

    // if(this.platform.is('ios')) {

    //   options.uri = 'fb://'

    // } else {

    //   options.packageName = 'com.instagram.android'

    // }

    

    this.appLauncher.canLaunch(options)

      .then((canLaunch: boolean) => {

        if (canLaunch) {

          this.appLauncher.launch(options).then(() => {

            

          },(err)=> {

              alert(JSON.parse(err));

          })

        } else {

          alert("Unable to lunch application.")

        }

     },(err)=> {

      alert(JSON.parse(err));

  });

  }

  open1() {

    

  }

}


  <ion-content>
    <ion-button (click)="open()">Open Insta app</ion-button>

    <!-- <ion-button (click)="open1()">second way Open Insta app</ion-button> -->
  </ion-content>

Comments

Popular posts from this blog

how to split array as per fixed length, and ionic two dates differences in min,seconds,hours

How to Add Firebase Analytics to Your NativeScript Mobile App