I've tested the following in both iOS 8 and iOS 9 devices. it works perfectly fine with iOS 8, but it doesn't work in iOS 9. can anyone please help?
Problem Solved. Solution: put this in info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
The original code
NSURL *scriptUrl = [NSURL URLWithString:@"http://google.com"];
NSData *data = [NSData dataWithContentsOfURL:scriptUrl];
if (data) {
NSLog(@"Device is connected to the internet");
}
else {
NSLog(@"Device is not connected to the internet");
}