How to Open External link in ionic app

2019-03-20 16:33发布

问题:

Anyone have a idea about how to open external link(outside from my ionic app) in my ionic app. when i tab on the link it will show my app if exsist in mobile.

回答1:

For opening a link with your app, you can use the custom-url-scheme cordova plugin . This enables you to open your app with an external link like testapp://path?foo=bar . Here is the link https://github.com/EddyVerbruggen/Custom-URL-scheme



回答2:

Install InAppBrowser:

ionic cordova plugin add cordova-plugin-inappbrowser

npm install --save @ionic-native/in-app-browser

Call your links like this:

window.open(url, '_system');


回答3:

As described here https://ionicframework.com/docs/native/in-app-browser/:

Install the Cordova and Ionic Native plugins:

$ ionic cordova plugin add cordova-plugin-inappbrowser
$ npm install --save @ionic-native/in-app-browser

Usage

constructor(private iab: InAppBrowser) { }
const browser = this.iab.create('https://ionicframework.com/');
// browser.show(), browser.close()


回答4:

You can Install the Cordova and Ionic Native plugins: Browser Tab.

ionic cordova plugin add cordova-plugin-browsertab
npm install --save @ionic-native/browser-tab

and

import { BrowserTab } from '@ionic-native/browser-tab';

constructor(private browserTab: BrowserTab) {

  browserTab.isAvailable()
  .then(isAvailable => {
  if (isAvailable) {
    browserTab.openUrl('https://ionic.io');
  } else {
    // open URL with InAppBrowser instead or SafariViewController
  }
 });
}

look here



回答5:

Install in App browser .

cordova plugin add cordova-plugin-inappbrowser

Use window.open for this

<a href="#" onclick="window.open('https://www.google.com/', '_system', 'location=yes');" >Google</a>

Refer this link http://intown.biz/2014/03/30/cordova-ionic-links-in-browser/