[Ionic2] Device Interaction in a Ionic App with Cordova Plugins

Source: Internet
Author: User

In this lesson, we is going to learn what to interact and native components through Cordova plugins. We'll walk through how to add a Cordova plugin to our application and use it for interact with our native device. In this case, we is going to install a plugin that would allow us to open URLs in a mobile browser from within our Ionic a Pp.

When your use of a link to open a webpage in Mobile ionic app, you'll find there is the no-on-the-back app.

<href= "https://google.fi">Go google, cannot come back the This app any More</a>

To solve this problem, we need to install a plugin:

NPM I--save-dev Cordova-plugin-inappbrowser

To check whether the plugin is successfully installed, you can do:

Ionic Plugin

It would list all the plugins and installed fot the application.

Now, let's try to open the link in browser instead for from app:

 <  a  href  = "https://google.fi"  >  Go Google, you cannot come-this app any More</ a   >  <  button  ion-button color  = "secondary"   (click)  = "Openinappbrowser ()"  >  Open in Browser</ >  
  Openinappbrowser () {    = "https://www.google.fi";    ' _system ');  }

Now upload the application to Ionic view:

Ionic upload

From the mobile phone, sync to latest version.

And we can confrim that if we click the button, this time, mobile would open the browser to display the page.

[Ionic2] Device Interaction in a Ionic App with Cordova Plugins

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.