Maps & Location

RSS for tag

Learn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.

Maps & Location Documentation

Post

Replies

Boosts

Views

Activity

Background location tracking not reliable
I'm writing an app in which the user is expected to initiate location tracking, let the app track for a period of time (a few minutes to a couple of hours) and then discontinue tracking. We want the user to be able to switch apps or let their device lock while tracking without losing any location updates. My understanding is that this can be done with the "While in use" location permission and does not require "Always". We don't want to have to ask our users for the "Always" permission. I'm configuring the location manager this way: locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation locationManager.allowsBackgroundLocationUpdates = true locationManager.showsBackgroundLocationIndicator = true locationManager.distanceFilter = kCLDistanceFilterNone locationManager.activityType = .otherNavigation locationManager.pausesLocationUpdatesAutomatically = false (The user is expected to be walking around in an outdoor location, stopping occasionally to take notes and pictures). I've tested this using both an iPhone and an iPad that relies on an external GPS device. It works. I can lock the device and see a continuous stream of location updates in the debugger for hours. I've also tested it while walking outdoors. However, my customer keeps reporting that the app stops tracking his location whenever it goes into the background. He says that it will track his location fine while in the foreground, but when he backgrounds it, it stops getting location updates. Then when it comes into the foreground again, it resumes. When we plot the locations on a map, you see a straight line between the place where the app went into background and where it woke up again. We know for sure that the app is just transitioning to and from the background and that it is not being terminated and restarted. I can't reproduce this result on my devices and can't figure out what I'm doing wrong. The customer says he has another app on his device (which is also an iPad with an external GPS) and that the other app does track him when it is in the background. My app does process all of the locations received in the didUpdateLocations method and not just the last one, so it's not that I'm getting the updates and ignoring them. I'm also not receiving any calls to 'locationManagerDidPauseLocationUpdates', 'didFinishDeferredUpdatesWithError', or 'didFailWithError'. The only explanation I can think of at the moment is that something changed in iOS. I know that the other app my customer is using is fairly old and built against an old version of the iOS SDK. Thanks for your help.
1
1
247
Jan ’25
How can you determine if the map tiles in MapKit have successfully loaded?
We are developers of a golf app designed to assist golfers on the course. A key feature of our app is displaying a map of each hole, and we are currently transitioning to using MapKit and camera functionalities for this purpose. However, we are encountering issues with the downloading of map tiles when using the default satellite imagery. We have tried several approaches to diagnose the issue: We have tried several things to diagnose the issue: We implemented the mapViewDidFailLoadingMap delegate method. But it is inconsistent, sometimes triggering offline errors even when map tiles are cached. We implemented, the mapViewDidFinishRenderingMap method, but it always returns false when offline or you won't get the callback. Which doesn't let us know that rendering tiles has failed. We would appreciate your guidance on the following specific questions: Does MapKit provide a way to confirm if a map tile has fully loaded? Is there a method to detect if a portion of the map hasn't loaded or if a tile request has failed? Can we determine whether a map tile is cached, and if so, how long it will remain cached, similar to Cache-Control HTTP headers? Is there a way to trigger the preloading of map tiles when we know the user has a good internet connection? Please see the sample project for steps to reproduce the issue. Thank you for any assistance!
3
0
279
Jan ’25
How to Reduce Geolocation Drifting Inside Buildings on iOS?
I am developing a Flutter app that uses geolocation data extensively. While the location accuracy is excellent under an open sky, I’ve noticed significant drifting when users are inside large buildings. This impacts the app’s functionality as precise location data is critical. I would like to know: Are there any specific configurations or APIs available in the Apple ecosystem to enhance indoor geolocation accuracy? Would combining GPS with other location technologies (like Wi-Fi or Bluetooth) reduce drifting effectively? Are there recommended practices for handling geolocation indoors on iOS? Any advice, examples, or guidance would be greatly appreciated!
1
0
228
Jan ’25
MapkitJS Snapshot
I am having issues loading in a mapkit snapshot. I get an error saying that https://domain.com and they're expecting domain.com. I have no idea what could be going wrong here. I set the domains properly in the mapkit tokens. When I click on the link it opens a new tab and loads what the data properly, but somehow in the application on production this error comes up.
0
0
232
Jan ’25
Request to Add an “AllowOnce” State to CLLocationManager
Context: Currently in iOS, both “Allow Once” and “While Using the App” location permission decisions yield .authorizedWhenInUse. This conflation prevents apps from knowing whether the user has provided a one-time allowance or a persistent in-use allowance. Problem Statement Ambiguous App Behavior: After a user selects “Allow Once,” the app remains in .authorizedWhenInUse, making it appear to the developer as if the user granted a more persistent “While Using” permission. Poor User Experience: If the user later indicates they want to upgrade to “Always,” developers must guess whether iOS will show another system prompt. This can lead to “dead” button presses or pointless transitions to Settings. Lack of Transparency: The user’s real intention—“I only trust you this one time”—gets lost in .authorizedWhenInUse with no direct or synchronous detection mechanism. Why This Wouldn’t Violate SRP The CLLocationManager’s` Single Responsibility: Manage and expose the user’s current location authorization state. Adding .authorizedOneTime or an isOneTime property fits neatly into that responsibility. It’s still describing the user’s level of trust for location usage, just with more specificity. No Overreach: This doesn’t add new logic outside location permissions—it merely refines the existing state definitions for clarity. Simplifies the Developer Flow: Instead of co-mingling “Allow Once” and “While Using,” the system returns the precise state, letting developers handle transitions more gracefully while abiding by iOS’s privacy rules. Benefits Improved UX: Developers can present more accurate prompts or guidance. If .authorizedOneTime, the app can immediately direct the user to Settings for a persistent upgrade, rather than futilely calling requestAlwaysAuthorization() again. Less Confusion: A distinctly reported “Allow Once” state eliminates guesswork, polling, or timed approaches that degrade user experience. Consistent with iOS’s Privacy Focus: Providing a read-only flag or status for “One Time” aligns with Apple’s approach to clarity around permissions, without letting apps forcibly bypass user intentions.
2
1
293
Jan ’25
MapKit UseAnnotation
using the UseAnnotation in the map content does not show the blue user location. I added the info.plist info. Error message: CLLocationManager(<CLLocationManager: 0x300e60d40>) for <MKCoreLocationProvider: 0x303e0e6d0> did fail with error: Error Domain=kCLErrorDomain Code=1 "(null)"
0
0
276
Jan ’25
Rotate mapkit.ImageAnnotation
Hello I'd like to be able to rotate an mapkit.ImageAnnotation. From this post on Stack Overflow https://stackoverflow.com/questions/78686475/need-to-style-a-mapkit-js-marker-annotation/78702266#78702266 I understand that it's possible, for example, to the following: map.annotations[0].element.style.cursor = "pointer"; and this works for me. However, I need to do something like the following, but it doesn't work: map.annotations[0].element.style.transform = "rotate(90deg) "; Any ideas how a mapkit.ImageAnnotation and mapkit.MarkerAnnotation can be rotated? Thanks in advance Sam
0
0
255
Jan ’25
How to correct business location?
My organization, Los Angeles Pierce College, rents space to "Topanga Vintage Market", which is a monthly weekend swap meet operation. Apple Maps shows the location as roughly 34.18715° N, 118.58058° W. However, this is the location of the campus Child Development Center, which provides child care services and is not open during the hours of the Topanga Vintage Market. The actual location should be in the adjacent large parking lot, roughly 34.18740° N, 118.57782° W. They do not have a physical building. How do I get this resolved? I am putting a campus mapping application into the App Store real soon now. There is also an entry for "ALC Taco Truck" about 34.18533° N, 118.57349° W, which as far as I know has not been on campus since Covid. Thanks in advance for any guidance you can provide.
1
0
366
Jan ’25
New CoreLocation APIs
Hi All, I am currently working on an app that has some navigation functionality, and since my minimum iOS is 18 wanted to incorporate the new APIs that yield a AsyncStream of locations. I have watched both WWDC sessions, the one where the new API is introduced to retrieve the location points, and also the other video where the new authorization process for location is simplified as well. I have an app currently working in its current state, but am noticing some weird quirks when using the CLBackgroundActivitySession to get the elevated background permission. What I am doing here is to create this stream and the background object is below: return AsyncThrowingStream { continuation in let task = Task { do { for try await update in CLLocationUpdate.liveUpdates(updateType) { if shouldStopUpdate { continuation.finish() break } continuation.yield(update) } } catch { continuation.finish(throwing: error) } } state = .started(locationTask: task, background: CLBackgroundActivitySession()) } When I have an active navigation session going and am strongly holding this object and the user force quits the app (or I stop the target through Xcode) the navigation activity indicator in the status bar (or dynamic island) remains present. Even if I relaunch the app, start navigation again, and then call the invalidate method on the CLBackgroundActivitySession I then am seeing that navigation indicator even if I delete my app, and often need to do a full restart to get out of this state. Is there a step I am missing, or do I not understand the way the new API works to run in the background?
1
0
405
Jan ’25
Location Push Service Extension in Limbo
Hi everyone, I submitted a request for the Location Push Service Extension entitlement back in November. I received an acknowledgment email from Apple confirming they had received my request, but I never heard back. Assuming the November request might have been lost in the shuffle, I submitted another request in January. It's been a week since then, and I still haven’t received any response. To follow up, I contacted Apple Support with my case number. Unfortunately, it seems they didn’t review the case properly, as the support assistant just sent me generic links about what to do when an app is rejected—which doesn’t apply here. Has anyone else experienced similar delays with this entitlement? Could there be specific reasons for such delays? Any tips on how to escalate this or get it addressed effectively would be greatly appreciated. Thank you in advance for your help!
0
0
233
Jan ’25
The latest IOS doesn't act for the custom iBeacon anymore.
I have some questions about the changes that the latest IOS doesn't act (scanning or monitoring) for our custom beacon devices. Since about 2015, We has provided some 'location based service' by using our custom iBeacon devices. However We've just realized that the latest IOS devices doesn't work with our custom iBeacon devices. but also realized It could still work with the other normal iBeacon devices. So, I've dig this issues for a while and finally I got the answer. It's because the one byte of Ibeacon advertsing packet payload. the followings are the differences about manufacturer data part between a normal Ibeacon and our custom beacon. normal Ibeacon 0xFF 0x4C00 0x02 0x15 0x736E75685F70656F706C655F74656331 0xEA61 0x03EB 0xC5 our custom Ibeacon 0xFF 0x4C00 0x02 0x15 0x736E75685F70656F706C655F74656331 0xEA61 0x03EB 0xC5 0xDA Yes, I know. after many of searches and research, Now I've understood the byte (meaning the length of following payload) should be changed as '0x16'. But It is certainly something that has worked well not so long ago. Anyway, The introduction was so long, but this is the one question what I'd like to ask about. I need to know exactly which version of IOS this change came from. (I've tried but I couldn't find any thing about this on the official documents.) I need to expaing to my customers what's going on. for that, I need the information that exactly which version of IOS It didn't work from. Thanks in advance. Regards.
1
0
281
Jan ’25
Documentation of parameters to enable Apple Maps EV routing
Hi, I'm building an aftermarket solution to enable Apple Maps to support EV routing for any EV. I am going through the documentation and found some gaps - does anyone know how the following properties work? INGetCarPowerLevelStatusIntentResponse - consumptionFormulaArguments INGetCarPowerLevelStatusIntentResponse - chargingFormulaArguments Is there a working example that anyone has seen? Many thanks
1
0
324
Jan ’25
Detecting Driving State with Core Motion Framework - Automotive Accuracy Issues
I am working on an iOS app where I need to detect when a user starts and stops driving using the Apple Core Motion framework. I've implemented the following MotionActivityManager class to handle activity updates and display the detected states in a SwiftUI view. While I can accurately detect "Stationary" and "Walking" states, detecting the "Driving" (Automotive) state has been unreliable. The accuracy often fails, and the framework frequently misclassifies driving as other states like "Unknown" or "Walking." Here's the implementation: @Published var motionStates: [MotionState] = [] @Published var startDate: String = "" @Published var confidence: String = "" init() { setupDefaultStates() startActivityUpdates() } private func setupDefaultStates() { motionStates = [ MotionState(label: "Stationary", value: false), MotionState(label: "Walking", value: false), MotionState(label: "Running", value: false), MotionState(label: "Automotive", value: false), MotionState(label: "Cycling", value: false), MotionState(label: "Unknown", value: false) ] } func startActivityUpdates() { guard CMMotionActivityManager.isActivityAvailable() else { print("Motion activity is not available.") return } motionActivityManager.startActivityUpdates(to: .main) { [weak self] motion in guard let self = self, let motion = motion else { return } DispatchQueue.main.async { self.updateProperties(with: motion) } } } private func updateProperties(with motion: CMMotionActivity) { motionStates = [ MotionState(label: "Stationary", value: motion.stationary), MotionState(label: "Walking", value: motion.walking), MotionState(label: "Running", value: motion.running), MotionState(label: "Automotive", value: motion.automotive), MotionState(label: "Cycling", value: motion.cycling), MotionState(label: "Unknown", value: motion.unknown) ] startDate = dateFormatter.string(from: motion.startDate) switch motion.confidence { case .low: confidence = "Low" case .medium: confidence = "Medium" case .high: confidence = "High" @unknown default: confidence = "Unknown" } } } struct MotionState: Identifiable { let id = UUID() let label: String let value: Bool } struct ContentView: View { @StateObject private var motionManager = MotionActivityManager() var body: some View { ScrollView { VStack(spacing: 16) { ForEach(motionManager.motionStates) { state in LabelView(label: state.label, value: state.value ? "True" : "False") } LabelView(label: "Confidence", value: motionManager.confidence) } .padding() } .onAppear { UIApplication.shared.isIdleTimerDisabled = true motionManager.startActivityUpdates() } .navigationTitle("Motion Activity") } } Issues: The motion.automotive state is often not detected accurately. The confidence level remains low for the automotive state, even when the device is clearly in a car. How can I improve the detection accuracy of the "Driving" state using the Core Motion framework?
1
0
264
Jan ’25
Granularity/Accuracy of delivered locations with live updates
First of all : Thanks for the great presentation (wwdc2023-10180), Siraj ! This new, simple API looks like what we've been looking for for easy manageable background location updates with 'automatic battery drain minimization' :-) There were two questions that came to my mind. As far as I understood, the CLLocationUpdate.LiveConfiguration is used to help the location services to improve the location fixes. Are there other options planned to specify the granularity of delivered locations e.g., how accurate the locations need to be (as the desiredAccuracy and distanceFilter settings for the olden CLLocationManager)? Does the Implementation switch between significant location changes and regular, more expensive ways (like GPS hardware) or just deliver the most feasible accuracy available at the time of notification? I'm just curious - if I get the most feasible granularity, everything is fine for me anyway :-) Thanks again, Michael
2
0
915
Jun ’23
Inquiry About Background Permission Issue in My App
I am writing to address a concern regarding the background permission functionality in my app, which is critical for ensuring user safety as they navigate various terrains. This feature also enables users to smoothly record their navigation tracks for review after their activities. Recently, I've noticed that this functionality is not working as seamlessly as before. Additionally, I observed that the app is not categorized under 'health and fitness'—could reclassifying it improve background activity? Before I delve into a detailed code review, I wanted to check if this issue might be related to sync or settings on the App Store side, such as permission configurations, app updates, or other related factors. Or, is it more likely an issue stemming from the app’s codebase?
1
0
319
Jan ’25
Warnings - Failed to locate resource
I have a test application I'm working on (so it's a fresh Xcode project under Sonoma - with older map code borrowed from another project). It is a macOS application. And in Obj-C. When the map window is opened the logs contain the following - I've been trying to hunt down and resolve. Thank you in advance for any clues/pointers. Failed to locate resource "default.csv" Failed to locate resource "satellite@2x.styl" Failed to locate resource "satellite@2x.styl" Failed to locate resource "satellite.styl" Failed to locate resource "satellite@2x.styl" Failed to locate resource "satellite@2x.styl" Failed to locate resource "satellite.styl" Failed to locate resource "satellite.styl" Couldn't find satellite.styl in framework, file name satellite.styl Authorization status: Authorized The application does have MapKit.framework included.
3
1
831
Dec ’24