[Ionic2] Device Interaction in an Ionic App with Cordova Plugins
In this lesson, we are going to learn how to interact with native components through Cordova plugins. We will walk through how to add a Cordova plugin to our application and use it to interact with our native device. In this case, we are going to install a plugin that will allow us to open URLs in a mobile browser from within our Ionic app.
When you use a link to open a webpage in mobile ionic app, you will find there is no way back to the app.
<a href="https://google.fi">Go Google, you cannot come back this app any more</a>
To solve that problem, we need to install a plugin:
npm i --save-dev cordova-plugin-inappbrowser
To check whether the plugin was successfully installed, you can do:
ionic plugin
it will list all the plugins you have installed fot the application.
Now, let's try to open the link in browser instead of from app:
<a href="https://google.fi">Go Google, you cannot come back this app any more</a>
<button ion-button color="secondary" (click)="openInAppBrowser()">Open in browser</button>
openInAppBrowser(){
const url = "https://www.google.fi";
window.open(url, '_system');
}
Now upload the application to ionic view:
ionic upload
From the mobile phone, sync to latest version.
And we can confrim that, when we click the button, this time, mobile will open the browser to display the page.
[Ionic2] Device Interaction in an Ionic App with Cordova Plugins的更多相关文章
- 方法:怎么用ionic命令行调试你的ionic app
官网上有很详细的解说 http://blog.ionic.io/live-reload-all-things-ionic-cli/ 下面说说我自己的调试过程(android版): 首先用命令行进入你 ...
- hybird app(混合式app开发)cordova ionic 创建相应平台的app
hybird app(混合式app开发) 之ionic 框架平台 guide cordova 创建相应平台的app 1. npm install -g cordova //全局安装cordova-cl ...
- ionic app打包和签名
ionic app打包和签名 1.首先在项目根目录执行 ionic platform add android 生成Android平台. 2.配置应用签名:在根目录下执行以下命令 keytool - ...
- Ionic App之国际化(3) json数组的处理
接上一篇Ionic App之国际化(2) json数组的处理 之后,如何处理json数据长度的问题,目前的一个折中方法是翻译长度字段. 多语言文件内容: "MyLa": { &qu ...
- Ionic App之国际化(2) json数组的处理
在Ionic App值国际化(1)中我们实现了对单个参数的多语言处理,下面开始如何进行数组的处理. 1.在我们的多语言文件中设置要访问的json数组,en.json和zh.json,此处就以en.js ...
- Ionic app 上传图片之webApi接口
App上传图片对应的webApi服务端是怎么处理的呢? using System; using System.Collections.Generic; using System.Diagnostics ...
- Ionic app升级插件开发
终于走到了写插件的这个地方了,插件的过程: 1.安装plugman插件,管理我们的程序 npm install -g plugman 2.创建插件项目appUpgrade,cd 到你的目标目录下,执行 ...
- 【ionic App问题总结系列】ionic 如何更新app版本
ionic 如何进行自动更新 ionic App更新有两种方式:第一种是普通的从远程下载apk,安装并覆盖旧版本.另外一种就是采用替换www文件夹的内容,实现应用内更新,而无需下载安装apk. 这篇文 ...
- ionic app 监听网络功能
安装cordova插件: cordova plugin add cordova-plugin-network-information 在app.js 的run()里面的function()注入$cor ...
随机推荐
- C_数组详解
数组: 一 一维数组 1.1 一维数组的定义: 类型符 数组名[常量表达式]; int a[10]; 说明: 1.数组的命名规则遵循标识符命名规则. 2.定义时需要指定元素的个数.方括号里的常量表达式 ...
- code blocks主题颜色配置
添加配置文件 注意:在添加这些自定义配置文件之前一定要先将之前的文件配置备份! 在添加时一定要确保Code::Blocks**没有**在运行!下载下面的文件,并将其添加到C:\Users\<你的 ...
- USACO 2009 Dec cow toll paths 过路费-floyd
这道题首先要明确一点,那就是当你从一个点走到自己时,也是需要花费这个点点权值的费用.这个点卡了我两次QWQ 然后我比较喜欢分两步搞: 首先,我们利用floyd的一个性质:就是在更新其他点之间的路线时要 ...
- 微信小程序实现tab页面切换功能
wxml <scroll-view scroll-x="true" class="ip_tab_comtainer"> <view class ...
- JavaScript学习总结(6)——js弹出框、对话框、提示框、弹窗总结
一.JS的三种最常见的对话框 [javascript] view plaincopy //====================== JS最常用三种弹出对话框 =================== ...
- Http请求连接池 - HttpClient 的 PoolingHttpClientConnectionManager
两个主机建立连接的过程是非常复杂的一个过程,涉及到多个数据包的交换,而且也非常耗时间.Http连接须要的三次握手开销非常大,这一开销对于比較小的http消息来说更大.但是假设我们直接使用已经建立好的h ...
- viewPager-基本实现示例
直接看代码 package com.example.myviewpager; import android.app.Activity; import android.os.Bundle; import ...
- 2.Spring Boot 入门
转自:https://blog.csdn.net/catoop/article/details/50501664
- h.264硬件解码
// H264HWDecoder.m // H264EncoderDecoder // // Created by lujunjie on 2016/11/28. // Copyright © 201 ...
- Ubuntu 12.04 64bit GCC交叉编译器制作 原创
...