aruku7230
aruku7230

Reputation: 981

how to test iOS device network is using IPv6 or IPv4?

iOS 9 will use IPv6-only network. To support IPv6, my iOS app have to stop using AF_INET (and many other apis such as struct in_addr), and instead, use AF_INET6.

But It should also support iOS 8 and earlier, so I have to continue to use AF_INET. The problem is how to know which network the system is using, IPv6 or IPv4? So I can use different apis according to different network condition.

Upvotes: 3

Views: 3214

Answers (2)

Mr.Kushwaha
Mr.Kushwaha

Reputation: 509

Apps are reviewed on an IPv6 network. Please ensure that your app supports IPv6 networks, as IPv6 compatibility is required.

i have used this code in AFNetworking Library in AFNetworkReachabilityManager Class and now it's working fine and my App is approved by Apple :)

+ (instancetype)sharedManager {
static AFNetworkReachabilityManager *_sharedManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{

#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
    struct sockaddr_in6 address;
    bzero(&address, sizeof(address));
    address.sin6_len = sizeof(address);
    address.sin6_family = AF_INET6;
#else
    struct sockaddr_in address;
    bzero(&address, sizeof(address));
    address.sin_len = sizeof(address);
    address.sin_family = AF_INET;
#endif
    _sharedManager = [self managerForAddress:&address];
});

return _sharedManager;
}

Upvotes: 1

Maninderjit Singh
Maninderjit Singh

Reputation: 1456

Solution for Apple app rejection due to IPv6 Network

My internet reachability check for IPv6 is not working well.It always shows absence of network.when I use this code ,apple approved my app within 24 hours. THANKS

Change the following line in code in AFNetworking Library in Class AFNetworkReachabilityManager

CHANGE AF_INET TO AF_INET6;

+ (instancetype)sharedManager {
    static AFNetworkReachabilityManager *_sharedManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        struct sockaddr_in address;
        bzero(&address, sizeof(address));
        address.sin_len = sizeof(address);
        address.sin_family = AF_INET6;  //Change AF_INET TO AF_INET6
        _sharedManager = [self managerForAddress:&address];
    });

    return _sharedManager;
}

Upvotes: -1

Related Questions