My problem: I need my app to search the local WiFi network to find a server computer with a application on a specific port. I don't want to hard code the server IP address into the app as it could be possibly used in many locations.
Update: So I need to be able to find the IP address of all devices on the network.
What iv done so far:
Iv followed other guides on stack overflow and online by doing the following steps:
1. install cordova plugin:
"cordova plugin add cordova-plugin-networkinterface"
2. Declare the variable in global scope to access the object
declare var NetworkInterface: any;
export class TestClass{}
3. Call the object using the global variable inside a component
NetworkInterface.getWiFiIPAddress((ip) => {
console.log("network ip address = " + ip);
});
However this causes an error on run time when running from the mobile:
ERROR Error: Uncaught (in promise): ReferenceError: NetworkInterface is not defined
I've also tried declaring a variable globally and then trying to apply a string value in a component, only to get the same problem. It appears to be more of a problem with the variable not working globally? Any help would be great!