Open AntonyCorbett opened 7 years ago
I was aware of that when it was written. Finding a proper solution for this can be tricky when dealing with devices that have multiple networks. The easiest is to ignore adapters that have routable IP addresses (e.g. not 192.x.x.x or 10.x.x.x). It is a quick fix, however it does not resolve all scenarios.
For example, if the user is connected to a VPN that is on an non-routable IP. In this case, two adapters will be returned, one for the local network and another for the VPN. In most cases this should not be an issue, but it's something to keep in mind.
If there is another library that is PCL compatible with Xamarin Android, IOS and UWP, perhaps I can change over to it. I tried other libraries but was unable to get them to work, especially with the testing framework.
The Acr.DeviceInfo.Connectivity.IpAddress does not always return the address we need (particularly on desktop devices where there are likely to be several adapters). The Acr code (shown below) is too simplistic in this case and can easily return the IP address for a virtual host
public string IpAddress => NetworkInformation.GetHostNames().Last().DisplayName;