Check for internet access with monotouch
-
21-09-2019 - |
Question
How can I check internet access with MonoTouch? I don't care if the internet comes from a WIFI or the Cell Network, all I care is whether there is internet access or not.
Solution
Using Miguel's Reachability class (found here: https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs) you can just call it like this:
if(!Reachability.IsHostReachable("http://google.com")) {
// Put alternative content/message here
}
else
{
// Put Internet Required Code here
}
Hope this helps,
ChrisNTR
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow