0

I am using Xamarin Forms to create both an Android and iOS app.

I am using Xamarin Essentials Connectivity (https://learn.microsoft.com/en-us/xamarin/essentials/connectivity) to detect connection changes which works great, except for one situation (so far). That is when there is a connection to a WiFi network but there is no actual Internet connection.

The app communicates with our API, so I need to know that there is an actual Internet connection available, before allowing anything that requires connection to the API.

Is this something that can be done better natively in Android and iOS? Or how can I detect that there is no Internet access and broadcast that within my app (so that various pages, etc, can react to the status change)?

GordonS
  • 193
  • 4
  • 9
  • 1
    Does this answer your question? [What is the best way to check for Internet connectivity using .NET?](https://stackoverflow.com/questions/2031824/what-is-the-best-way-to-check-for-internet-connectivity-using-net) – GSerg Nov 01 '21 at 11:34
  • @GSerg - I need to read it all in detail (and try to relate it to Xamarin/Android/iOS) but the comments seem to indicate there is no reliable way to do it. They suggest try call API and capture error instead, but I would like to be able to show / hide a "No Internet" msg. – GordonS Nov 01 '21 at 11:47
  • 1
    Correct, there is no reliable way to do it, which the main takeaway from that question. Whatever type of check you can come up with, imagine this very thing is specifically blocked in the firewall, whereas everything else is allowed. And don't forget that the answer you get is only valid for *a moment ago*, as the connectivity may disappear right after you checked it's there. – GSerg Nov 01 '21 at 13:23
  • OK, well at least that gives me a direction to take for a solution to suit my needs. – GordonS Nov 01 '21 at 14:12
  • check if it has what you want https://nugetmusthaves.com/Tag/wifi – Adrain Nov 02 '21 at 01:55
  • I haven't tried it, but I like the looks of [this answer](https://stackoverflow.com/a/44025507/199364) from that proposed duplicate. That should be quicker than the suggestions to query google's home page. And it links to a discussion that says this technique is used w/i Android itself. – ToolmakerSteve Nov 03 '21 at 06:24

0 Answers0