Internet connection check API for monotouch in 64bit iOS?

ChunweiZhengChunweiZheng USMember
edited April 2015 in General

I have a problem in checking internet connection.
I am using MvvmCross and just update the sourcode to 64bit.
No matter the old/new sourcecode works in my iphone 5,
however, when using iphone 6, or ipad mini3 etc, with the LTE and WIFI both working
the network connection part would cause screen freeze for a while (several seconds) before the next operation.
If I turned of the LTE or Cellular (use WIFI) only the problem is solved as well.
I tried debugging, but there is no same stuck when debugging

SO I wonder that would be the reason for 64 bit support?
1) the function below not support 64 bit platform yet
2) the function I am using is not correct ( why iphone 5 working OK )
3) once both network are available, the function logic need to change? or just the API not support LTE network yet?

Here is the sourcecode for network check internet

    public bool TestInternet() {

        using (var r = new NetworkReachability("www.hotmail.com"))
        {
            NetworkReachabilityFlags flags;

            if (r.TryGetFlags(out flags))
            {
                return IsReachableWithoutRequiringConnection(flags);
            }
        }

        return false;
    }

    public static bool IsReachableWithoutRequiringConnection(NetworkReachabilityFlags flags)
    {
        // Is it reachable with the current network configuration?
        bool isReachable = (flags & NetworkReachabilityFlags.Reachable) != 0;

        // Do we need a connection to reach it?
        bool noConnectionRequired = (flags & NetworkReachabilityFlags.ConnectionRequired) == 0;

        // Since the network stack will automatically try to get the WAN up,
        // probe that
        if ((flags & NetworkReachabilityFlags.IsWWAN) != 0)
            noConnectionRequired = true;

        return isReachable && noConnectionRequired;
    }

Answers

Sign In or Register to comment.