Reputation:
I am back and have a question on map-kit and the internet connection. I have a app which tracks the user but when i turn off cellular data and wifi its tracks the user and shows the wrong distance. I want to turn off maps if there are no internet and when there is internet turn on the maps. Thank You in Advance.
Upvotes: 0
Views: 136
Reputation: 3655
Take a look at Apple's reachability project that tests Internet reachability, and just implement it in your app to hide/show the map.
This is also a good step-by-step tutorial
The great thing about this is that it works with notifications, so you can react to changes in the network and not only to whether the network was available at the start of the application.
Once you include it in your project it can be as simple as:
Reachability *reach = [Reachability reachabilityForInternetConnection];
NetworkStatus status = [networkReachability currentReachabilityStatus];
if (status == NotReachable) {
// hide map
} else {
// show map
}
Upvotes: 1