iOS Location Services Settings
In Standard Location Provider III, we hooked up the StandardLocationProvider, but we denied LSDemo use of the iPhone Location Services. As a result, whenever we launch the app, we get an error:
Click the "Location Services" setting.
Notice the location services for the sandbox app "LSDemo" have been disabled. Turn it On by sliding the switch:
Finally, press the Home button again and re-launch LSDemo app. In the Xcode console, you should now see a stream of updates like this:
Disabling Location Services
What happens if we disable Location Services completely? Let's try. Click the Home button again and open the Settings app. This time though, disable all Location Services by sliding the switch at the top to Off:
Then re-launch LSDemo. You will see this alert popup:
If you click "Cancel" at this point, the app will just hang. There will be no error and no location updates will be sent. If we re-launch the app and click "Cancel" a second time, LSDemo will be completely disabled, and the alert will stop appearing altogether. To restore the alert popup, delete LSDemo from the iPhone simulator entirely and re-launch the app from within Xcode.
This time, click "Settings" to be taken back to the Location Services screen. Slide the switch to turn them back On, and likewise enable Location Services for LSDemo. Click the Home button in the simulator and return to the app. Now, you should again see the familiar stream of updates in the Xcode console:
Notice the coordinates <+37.78583400,-122.40641700>. Where is the app getting this location, and how can we change it? In the next post we shall find out.
2011-11-10 11:27:50.285 LSDemo[20652:f803] error=Error Domain=kCLErrorDomain Code=1 "The operation couldn’t be completed. (kCLErrorDomain error 1.)"To fix this, click the Home button on the simulated iPhone and open the Settings app.
Click the "Location Services" setting.
(Your locations may vary.) Yay! The app is behaving just as we expected.2011-11-10 11:33:29.432 LSDemo[20715:f803] newLocation=<+37.78583400,-122.40641700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 11/10/11 11:33:29 AM Pacific Daylight Time
2011-11-10 11:33:29.433 LSDemo[20715:f803] oldLocation=(null)2011-11-10 11:33:30.278 LSDemo[20715:f803] newLocation=<+37.78583400,-122.40641700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 11/10/11 11:33:30 AM Pacific Daylight Time2011-11-10 11:33:30.280 LSDemo[20715:f803] oldLocation=<+37.78583400,-122.40641700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 11/10/11 11:33:29 AM Pacific Daylight Time
Disabling Location Services
What happens if we disable Location Services completely? Let's try. Click the Home button again and open the Settings app. This time though, disable all Location Services by sliding the switch at the top to Off:
Then re-launch LSDemo. You will see this alert popup:
If you click "Cancel" at this point, the app will just hang. There will be no error and no location updates will be sent. If we re-launch the app and click "Cancel" a second time, LSDemo will be completely disabled, and the alert will stop appearing altogether. To restore the alert popup, delete LSDemo from the iPhone simulator entirely and re-launch the app from within Xcode.
This time, click "Settings" to be taken back to the Location Services screen. Slide the switch to turn them back On, and likewise enable Location Services for LSDemo. Click the Home button in the simulator and return to the app. Now, you should again see the familiar stream of updates in the Xcode console:
Yay! Now we know what happens when Location Services are disabled.2011-11-10 11:44:15.453 LSDemo[20964:f803] newLocation=<+37.78583400,-122.40641700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 11/10/11 11:44:15 AM Pacific Daylight Time2011-11-10 11:44:15.456 LSDemo[20964:f803] oldLocation=<+37.78583400,-122.40641700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 11/10/11 11:44:14 AM Pacific Daylight Time
Notice the coordinates <+37.78583400,-122.40641700>. Where is the app getting this location, and how can we change it? In the next post we shall find out.