Always failed to receive in iOS7

Previously, I always used Tony Million "Accessibility" , and it always worked fine. Now I also tried the Apple Reach ability , but every time I try to access, I always get a message about the lack of Internet.

Is there anything else I should check?

Here is what i did

  Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"];

    reach.reachableBlock = ^(Reachability * reachability)
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            blockLabel.text = @"Block Says Reachable";
        });
    };

    reach.unreachableBlock = ^(Reachability * reachability)
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            blockLabel.text = @"Block Says Unreachable";
        });
    };

    [reach startNotifier];
+3
source share
5 answers

You can also use to check your Internet connection. First you need to import to a file

#import <SystemConfiguration/SCNetworkReachability.h>
#include <netinet/in.h>

in .h file

- (BOOL) connectedToNetwork
{

    struct sockaddr_in zeroAddress;
    bzero(&zeroAddress, sizeof(zeroAddress));
    zeroAddress.sin_len = sizeof(zeroAddress);
    zeroAddress.sin_family = AF_INET;

    SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *)&zeroAddress);
    SCNetworkReachabilityFlags flags;

    BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags);
    CFRelease(defaultRouteReachability);

    if (!didRetrieveFlags)
    {
        return NO;
    }

    BOOL isReachable = flags & kSCNetworkFlagsReachable;
    BOOL needsConnection = flags & kSCNetworkFlagsConnectionRequired;
    return (isReachable && !needsConnection) ? YES : NO;
}

If these methods return YES, then an Internet connection is available.

May this help you ...

+4
source

, Reachability.m 3g.

#if TARGET_OS_IPHONE
    if(flags & kSCNetworkReachabilityFlagsIsWWAN)
    {
       // We're on 3G.
       if(!self.reachableOnWWAN)
          {
          // We don't want to connect when on 3G.
           connectionUP = NO;//Commit this line
         }
    }
#endif

, .

#if TARGET_OS_IPHONE
    if(flags & kSCNetworkReachabilityFlagsIsWWAN)
    {
       // We're on 3G.
       if(!self.reachableOnWWAN)
          {
          // We don't want to connect when on 3G.
           //connectionUP = NO;
         }
    }
#endif
+2
    Reachability *r = [Reachability reachabilityWithHostName:@"www.Google.com"];
    NetworkStatus internetStatus = [r currentReachabilityStatus];

    if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN))
    {
        blockLabel.text = @"Block Says Unreachable";
    }
    else
    {
        blockLabel.text = @"Block Says Reachable";
    }
+1
source
+1
source

I have the same problem with Tony Million Reachability: the network status has always been set to NotReachable. I am fixing this with the addition of Framework SystemConfiguration

Hope this helps

+1
source

All Articles