Search code examples
ibm-mobilefirstcordova-plugins

How do I get the IPAddress in Cordova apps


I am working on upgrading my MFP app from 7.1 to 8.0 and one of issue identified by the migrate script is that the WL getNetworkInfo() API is discontinue and I have to used Cordova network info plugin

However, I don't see a method in the Cordova Plugin class to to get the Ip address

Here is call I make in IBM MFP 7.1:

WL.Device.getNetworkInfo(function (networkInfo) {
alert (networkInfo.ipAddress);  
});

How do i get the IP in Cordova apps?


Solution

  • This repo looks very promising https://github.com/salbahra/cordova-plugin-networkinterface.

    //CLI
    cordova plugin add cordova-plugin-networkinterface
    
    //JS
    networkinterface.getIPAddress(function (ip) { alert(ip); });