MΓ³dulo 11 Β· Live GPS Tracking β LecciΓ³n 2 de 3 Β· ~15 min
CoreLocation: Real GPS In
The other direction
Lesson 1 was fixes flowing down the socket. But somebody has to produce them β and on the walker's phone, that somebody is the device's real GPS. Apple's framework for it is CoreLocation, and the object you talk to is CLLocationManager.
Location is sensitive, so iOS gatekeeps it: the first time the app asks, the user sees a permission alert, and the app must declare why in Info.plist (PawWalk's entry: "PawWalk shows the walk happening live on the map."). In code, the ask is one call β requestWhenInUseAuthorization() β "when in use" meaning only while the app is on screen.
Two knobs tune the firehose before it starts:
desiredAccuracyβ how precise you want fixes.kCLLocationAccuracyBestasks for the best the hardware can do.distanceFilterβ how far (in metres) the device must move before you're told about a new fix.