Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

CrossConnectivity.Current.IsReachable always return true

HannahCHannahC Member ✭✭

My Xamarin iOS APP wants to check the Internet connectivity through CrossConnectivity API.
I found that the "resp" always returns true whether Internet is worked or not. (even if I unplugged the router, the API returns "true")

bool resp = await CrossConnectivity.Current.IsReachable("google.com", 5000); //resp = true

Otherwise, I change the host to "8.8.8.8", the API always returns false even if the Internet is worked.
bool resp = await CrossConnectivity.Current.IsReachable("8.8.8.8", 5000); //resp=false
Is anyone know how to fix this issue?

Xaml.Plugin.Connectivity(Version:3.2.0)

Best Answer

Answers

  • HannahCHannahC Member ✭✭
    edited October 2020

    @LeonLu said:
    Please update your nuget packages to 4.0.0.190-beta(If you do not have the version, please select the show pre-release packages), I test it in IOS 14, it worked as charm.

    Hi LeonLu, your solution is worked! Thanks for your big help!
    I upgrade the package to 4.0.0.190-beta first and try again.

    The code with '8.8.8.8' is working accurately.
    bool resp = await CrossConnectivity.Current.IsReachable("8.8.8.8", 5000);
    //Router has Internet connection -> API returns true
    //Router has no Internet connection -> API returns false

    But the code with 'google.com' has the strange result, so it might be the wrong way to check if the router has Internet connection or not.
    bool resp = await CrossConnectivity.Current.IsReachable("google.com", 5000);
    //Router has Internet connection -> API returns true
    //Router has no Internet connection -> API returns true

    My problem is resolved.

Sign In or Register to comment.