Cordova - How to get device IP address?
I use the IP module from npm to handle all my IP address manipulation. It works fine on desktop but it just returns 127.0.0.1 on Android.
I’ve tried the cordova-plugin-networkinterface but I can’t seem to get it to work. It appears to be dependent on the ionic framework.
So how you go a out getting the devices local up address in Quasar/Cordova?
Do you mean local as in local subnet? Or the IP address it appears to be to the outside world? I just use an axios call to one of the what-is-my-ip services to return that to my app, would that work?
metalsadman last edited by
Not a quasar related issue.
@metalsadman no but in the greater context of building Cordova apps with the Quasar framework, I would entertain just about any question in these forums. It’s about sharing knowledge after all.
I’m may case, where I connect to multiple user’s Plex servers, it’s important to know the devices LAN ip address in order to decide whether the user and their server are on the same local network or if they need to connect to it over the internet.
Again, on desktop this is a trivial matter. I’m surprised, however, that there is no some way to get this information in Cordova. How incredibly frustrating.
@ssuess I get the users ip address and the servers up address that they want to connect with.
I then check if both IPs are on the same subnet. If so, I connect to the local server address. If not, I connect to the servers public address.
@wwwizzarrdry maybe try installing this plugin: https://ionicframework.com/docs/v3/native/network-interface/
@ssuess Thanks, that’s literally the exact plugin I referenced in the title of this post.
I’ve tried adding the plug-in several times, but whenever I try to call:
networkinterface.getWiFiIPAddress( onSuccess, onError );
networkinterfaceobject is not defined. I installed the plug-in from within the ```
If you come across this post, I was never able to get the aforementioned module to work with my quasar app.
However I finally stumbled upon this, which should do the trick.
@wwwizzarrdry could you give code example pls? i was try using example code from documentation that plugin, but still not working