This objective-c iOS code checking the internet connection. The Url string “https://1.1.1.1” is the fastest ping server for respond data. You can change the Urls string to what you want.
NSURL *Urlcheck = [NSURL URLWithString:@"https://1.1.1.1"]; NSData *data = [NSData dataWithContentsOfURL:Urlcheck]; if (data){ //your code } else { // your code if no internet connection }