Table of Contents
This Cordova plugin for Android is used to request the information of network such as ip address, network address and network mask.
This plugin must not depend on libraries only present in API 23+, so you don't need build using Android SDK Platform v23 or above. This removes the dependency on API 23 and will allow you to build against legacy API versions (22 and below). You can check the currently installed platform versions with the following command:
cordova platform ls
IMPORTANT: Note that the plugin will NOT work in a browser-emulated Cordova environment, for example by running cordova serve
or using the Ripple emulator.
This plugin is intended to launch native navigation apps and therefore will only work on native mobile platforms (i.e. Android).
$ cordova create MiTV5 com.movistar.tvsindesco movistartv
$ cd MiTV5
$ cordova platform add android
$ cordova plugin add https://github.com/portizb/NetworkInfoPlugin.git
To run an example project on Android using the Cordova CLI:
cordova build android
Edit www/js/index.js
and add the following code inside onDeviceReady
for test the plugin
var success = function(message) {
alert("ipAddress: " + message.ipAddress +
", gatewayAddress: " + message.gatewayAddress +
", networkAddress: " + message.networkAddress +
", subnetMask: " + message.subnetMask);
}
var failure = function() {
alert("Error calling Network Information Plugin");
}
netinfo.lookup(success, failure);
cordova run android
For more information on setting up Cordova see the documentation
For more info on plugins see the Plugin Development Guide