Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Network check for wifi 3g 4g

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 195
    Comment on it

    Hi Guys,

    You can use this function before hitting any server api. This will check whether your device is connected to network or not.

    + (BOOL)isNetworkAvailble{
        const char *host_name = "";
        BOOL _isDataSourceAvailable = NO;
        Boolean success;
        //Creates a reachability reference to the specified
        //network host or node name.
        SCNetworkReachabilityRef reachability =
        //Determines if the specified network target is reachable
        //using the current network configuration.
        SCNetworkReachabilityFlags flags;
        success = SCNetworkReachabilityGetFlags(reachability, &flags);
        _isDataSourceAvailable = success &&
        (flags & kSCNetworkFlagsReachable) &&
        !(flags & kSCNetworkFlagsConnectionRequired);
        if (!_isDataSourceAvailable) {
            [self showAlertMessage:ALERT_NETWORK_ERROR];
        return _isDataSourceAvailable;


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: