问题描述
我的工作离子框架和科尔多瓦。我想提出一些数据到服务器
但是当这两个条件都满足
1.设备联机。
2.数据(提交)是可用的。
我检查这个科尔多瓦网络插件但我搞不清是有它太多的怪癖。我怎么能写有效code为所有设备(Android的手段,赢手机,IPhone等),还我怎样才能得到用户的IP地址?
我已经试过,工作在浏览器不错,但不敢来实现事业的手机可以忽略这条线(我猜)
$ scope.checkOnline = navigator.onLine;
这很容易,你只需要使用两个科尔多瓦插件这样的:
- 插件1:科尔多瓦-插件-的NetworkInterface
例如:
networkinterface.getIPAddress(功能(IP){
警报(IP);
});
工作的例子,教程,点击
例如:
document.addEventListener(在线,onOnline,FALSE);功能onOnline(){
//处理在线活动
}
插件文档,请点击。
I am working on Ionic Framework and cordova. I want to submit some data to serverbut when these two condition are satisfied1. device is online.2. data (to submit) is available .
i am checking this cordova network plugin documentation but i am confuse that there is too many quirks in it. How can i write valid code for all devices(means android, win Phone, IPhone etc..) and also how can i get user IP Address.??i have tried this, working fine in browser but afraid to implement cause mobile phone can ignore this line (i guess)
$scope.checkOnline = navigator.onLine;
It's easy, you only need to use two Cordova plugins for this:
- Plugin 1: cordova-plugin-networkinterface
Example:
networkinterface.getIPAddress(function (ip) {
alert(ip);
});
Working example and tutorial, click here.
- Plugin 2: cordova-plugin-network-information
Example:
document.addEventListener("online", onOnline, false);
function onOnline() {
// Handle the online event
}
Plugin documentation, click here.
这篇关于如何获得用户IP地址,确保用户在离子\\科尔多瓦在线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!