Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve iOS Support #5

Open
Vitormdias opened this issue Jan 9, 2019 · 2 comments
Open

Improve iOS Support #5

Vitormdias opened this issue Jan 9, 2019 · 2 comments

Comments

@Vitormdias
Copy link
Contributor

Today it fetches google.com and there is a better way to check the internet connection.
I don't recommend using Reachability because if you do it won't be approved by Apple Store

@tzraeq
Copy link

tzraeq commented Jan 21, 2019

Today it fetches google.com and there is a better way to check the internet connection.
I don't recommend using Reachability because if you do it won't be approved by Apple Store

Would please share your solution?

@Vitormdias
Copy link
Contributor Author

I think this should work @tzraeq

+(bool)isNetworkAvailable
{
    SCNetworkReachabilityFlags flags;
    SCNetworkReachabilityRef address;
    address = SCNetworkReachabilityCreateWithName(NULL, "www.apple.com" );
    Boolean success = SCNetworkReachabilityGetFlags(address, &flags);
    CFRelease(address);

    bool canReach = success
                    && !(flags & kSCNetworkReachabilityFlagsConnectionRequired)
                    && (flags & kSCNetworkReachabilityFlagsReachable);

    return canReach;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants