O'Reilly logo

iPhone Location Aware Apps by Example by Zeeshan Chawdhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — checking for location service availability

Before we start using the iOS location framework, it is important to know whether location services are enabled on the user's device or not. If location is off, then we can prompt the user to switch it on.

Let's reuse the Hello Location example to check for location service availability:

  1. Open the Hello Location example and modify the viewDidLoad method in the Hello_locationViewController.m file to look like the following code snippet:
    locMgr = [[CLLocationManager alloc]init];
    if([CLLocationManager locationServicesEnabled])
    {
    locMgr.startUpdatingLocation;
    }
    
  2. You can manage your iOS device's location settings at Settings | Location Services. Starting with iOS 5, location services ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required