2

I am using this code for detecting if there is internet connection:

Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
    NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];
    if (networkStatus == NotReachable) {
        [UIView showSimpleAlertWithTitle:nil
                                 message:locs(@"8614aa-alert_connection_message", lpos_alert_message)
                       cancelButtonTitle:@"OK"];
        return;
    }

It works. But I have problem when there is cellular data connection and my app is blocked. It returns WWAN but I can't connect. So how can I detect if my app is blocked or not? Thanks

Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
  • you should not use reachability for that purpose, you just need to start the request directly, and handle the _failure_ and _completion_ events. – holex Nov 24 '14 at 12:26
  • I hope that there is something that I could add `else if (networkStatus == ReachableViaWWAN && !SystemConfiguration.AppCellularBlocked) [UIView showAlert ...` Simple detection if there is only cellular connectivity and I have blocked cellular then no connection. – Libor Zapletal Nov 24 '14 at 12:35
  • the original concept is wrong 1. why would you make a pre-request before you'd make your final one? 2. the cellular connection is available for every app basically, and the actual end-user _explicitly_ needs to disable that. – holex Nov 24 '14 at 12:52
  • This capability is available for iOS9 or later using CTCellularData. See https://stackoverflow.com/a/48160099/2941876 – Paul King Jan 09 '18 at 01:16

0 Answers0