[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 ...
随机推荐
- POJ 2981 Strange Way to Express Integers 模线性方程组
http://poj.org/problem?id=2891 结果看了半天还是没懂那个模的含义...懂了我再补充... 其他的思路都在注释里 /********************* Templa ...
- SQL insert 主键冲突
待总结 https://blog.csdn.net/JavaCoder_juejue/article/details/82313891 https://blog.csdn.net/a772304419 ...
- 洛谷——P3384 【模板】树链剖分
https://www.luogu.org/problem/show?pid=3384#sub 题目描述 如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作: 操作 ...
- java.lang.ClassNotFoundException: org.springframework.web.content.ContextLoaderListener
1.错误描写叙述 严重: Error configuring application listener of class org.springframework.web.content.Context ...
- Day5下午解题报告1
预计分数:100+60+30=190 实际分数:100+60+30=190 终于有一道无脑T1了哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈 ...
- 【习题 7-8 UVA-12107】Digit Puzzle
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 迭代加深搜索. 枚举最大层数.(也即改变的数字个数 然后枚举第一个改哪个数字,第二个改哪个数字.. 一定要注意字典序问题. 每次优先 ...
- 【2017"百度之星"程序设计大赛 - 初赛(B)】度度熊的交易计划
[链接]点击打开链接 [题意] 在这里写题意 [题解] 先设一个超级源点,向每个片区都建一条边,容量为b,费用为-a; 然后从每个片区再连一条边,指向一个超级汇点. 容量为d,费用为c; 然后从起点到 ...
- 【LightOJ - 1205】Palindromic Numbers
[链接]https://cn.vjudge.net/problem/LightOJ-1205 [题意] 求出L..R范围内的回文个数 [题解] 数位DP; 先求出1..x里面的回文串个数.则做一下前缀 ...
- Eclipse中Git插件使用技巧:[5]还原文件
如果修改了某个文件并未提交至本地库(add index),那么怎么还原呢?Git插件中并不像Svn插件直接提供有还原方式.其实无论是否提交至本地库或者远程库,还原操作的本质都是将文件的当前版本还原至之 ...
- React render return 空行问题
Uncaught Invariant Violation: App.render(): A valid React element (or null) must be returned. You ma ...