[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 ...
随机推荐
- PythonOOP面向对象编程1
什么是对象? 对象是指现实中的物体或实体(拥有一系列变量.函数(方法)的) 什么事面向对象? 把一切看成对象(实例),让对象和对象之间建立关联关系 对象都有什么特征? 属性(名词)实例变量 姓名.年龄 ...
- 小米开源文件管理器MiCodeFileExplorer-源码研究(4)-文件操作工具类FileOperationHelper
文件操作是非常通用的,注释都写在源代码中了,不多说~需要特别说明的是,任务的异步执行和IOperationProgressListener.拷贝和删除等操作,是比较费时的,采用了异步执行的方式~ An ...
- Java数据传递实验
本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 在开发过程中,我们经常会遇到对象传递的问题,有时仅仅传递数据,有时却要实现数据同步:这时,就要分清两 ...
- [翻译]魅族的M1 Note是十分廉价(dirt-cheap)的iphone5C增强版
Meizu's M1 Note is a dirt-cheap iPhone 5c on steroids 魅族的M1 Note是十分廉价(dirt-cheap)的ihone5C增强版 While m ...
- HDU 2102 A计划 (三维的迷宫BFS)
题目链接:pid=2102">传送门 题意: 三维的一个迷宫,起点在第一层的S(0,0,0)处,问是否能在规定的时间内走到第二层的P 处.'*'代表不能走,'.'代表能够走,'#'代表 ...
- JavaScript的子集和超集
1.JavaScript子集 JavaScript子集的定义大部分都是出于安全考虑,仅仅有使用这门语言的一个安全的子集编写脚本,才干让代码运行得更安全.更稳定.比方怎样更安全地运行一段由不可信第三方提 ...
- IIS进程回收 空闲时Net线程未运行
最近手上的项目,用的是asp.net mvc,后台有个线程在循环接收socket数据,本身在系统运行的时候访问页面没问题,但是发现没访问时,后台没有接收数据,后来知道了是IIS把线程回收了.解决方法如 ...
- Dell shareplex 与HVR数据复制软件
今天大体了解了一下Dell shareplex 数据复制软件,网址为:http://software.dell.com/products/shareplex/ 从该网址能够看到. shareplex作 ...
- thinkphp动态注册路由
thinkphp动态注册路由 一.总结 1.thinkphp使用路由步骤:a.config配置文件中开启路由 b.Route类的rule方法创建路由(在Routephp中)Route::rule(' ...
- IDEA配置svn地址方法及出现的问题的解决办法
1.在IDEA中点击File-Settings里面,如图所示,选择你本地装的svn的exe路径: 2.在如图所示菜单中配置svn地址: 问题1:如果svn路径下没有exe文件,则是装svn的时候没有安 ...