When I quit the app from the background task list, CLLocationUpdate.liveUpdates does not resume properly and start location updates. However, if I kill the app directly, it can recover and start location updates.
Maps & Location
RSS for tagLearn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.
Post
Replies
Boosts
Views
Activity
The easiest way to explain this is to show it. On any device, open Maps, set it to Driving (which will show traffic). Go to Baltimore Maryland. In the water just south east of the city there is a bridge (Francis Scott Key Bridge). . On Apple Maps the road is colored dark red.
At certain zoom levels, there is a "button" (red circle with a white - in it). When you click on that "button", it says 1 Advisory (Road Closed).
How do I show this "button" on my map. My map shows the dark red color, but no "button" appears.
The only "advisory" that I've been able to find is when you create a route. Of course you can't create a route over a road that fell into the water.
struct ContentView: View {
@State private var position = MapCameraPosition.region(
MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 39.22742855118304, longitude: -76.52228412310761),
span: MKCoordinateSpan(latitudeDelta: 0.05407607689684113, longitudeDelta: 0.04606660133347873)
)
)
var body: some View {
Map(position: $position)
.mapStyle(.standard(pointsOfInterest: .all, showsTraffic: true))
.cornerRadius(25)
}
}
Is this a WCDWAD, or is there a way to show the "button"
(We Can't Do What Apple Does)
I'm currently developing an app with mapkit which I may submit to the Swift Student Challenge. So anyways, the app will be used completely offline. I was wondering if there was any way to include very low resolution map tiles with the app files. That way, the app never needs wifi. However, I'm not sure if this is possible, especially since the map would need to be under 20 mb. Thanks.
Note: I have had issues with CMAltimeter since whats seems to have been a major undocumented modification since iOS 17.4.
So I'm using the CMAltimeter absolute locations delivery.
Sometimes, the altimeter seems to be in an uncalibrated mode and therefore, no altitude delivery happens.
Is there a way to be inform of such state? Currently, it just doesn't work and I can't inform the user about this. They just think the app is broken
What message should I give to the users to accelerate the calibration such that the CMAltimeter will work again?
Also, users have reported that the CMAltimeter can temporarily stop delivering altitude updates, even though it should.
So I guess my question resumes to this:
Whats the best practice to handle an uncalibrated CMAltimeter?
Thanks!
I am working on a duress app and would like to improve location accuracy by encouraging users to enable Wi-Fi. In Apple Maps, I noticed that when Wi-Fi is off, a dialog prompts users to turn on Wi-Fi to enhance location accuracy. I am looking to implement similar functionality in my app.
Specifically, I would like to check whether Wi-Fi is enabled on the user's device (even if it is not connected to a network). Despite exploring several methods, I have been unable to determine a reliable way to check the Wi-Fi status.
Can you guide me on whether it is possible to access this functionality in iOS, and if so, how I can implement it within my app?
We (at the NYC MTA) are building a new subway/bus app and diving deep into location tracking on iOS. We’re encountering an issue with how Core Location functions in the subway, specifically regarding how long it takes to update a passenger’s location as they travel from station to station.
As an example, please see this video: https://drive.google.com/file/d/1yaddkjyPEETvTEmClPAJ2wks8b-_whqB/view?usp=sharing
The red dot is set manually (via a tap gesture) and represents the ground truth of where the phone actually is at that moment. The most critical moment to observe is when the train physically arrives at a station (i.e., when I can see the platform outside my window). At this moment, I update the red dot to the center of the station on the map. Similarly, I adjust the red dot when the train departs a station, placing it just outside the station in the direction of travel.
The trip shown is from Rector St to 14 St. All times are in EST.
I’d like to investigate this issue further since providing a seamless underground location experience is crucial for customers. As a point of comparison, Android phones exhibit near-perfect behavior, proving that this is technically feasible. We want to ensure the iOS experience is just as smooth.
The code below using LookAroundPreview works fine on iOS (showing the preview image with a button saying "Look Around" at the top to enter full screen with navigation), but on macOS (15.3) there is no button and no way to navigate the view. Is this a bug or is there something I need to do differently on macOS? I have also tried using AppKit with MKLookAroundViewController and I don't seem get the button to launch full screen there either.
import SwiftUI
import MapKit
struct ContentView: View {
var body: some View {
LookAroundPreviewView(coordinate: CLLocationCoordinate2D(latitude: 37.33182, longitude: -122.03118))
.frame(width: 300, height: 200)
}
}
struct LookAroundPreviewView: View {
let coordinate: CLLocationCoordinate2D
@State private var scene: MKLookAroundScene?
@State private var errorMessage: String?
var body: some View {
Group {
if scene != nil {
LookAroundPreview(scene: $scene, allowsNavigation: true)
} else if let errorMessage = errorMessage {
Text("Error: \(errorMessage)")
.foregroundColor(.red)
} else {
ProgressView("Loading Look Around Preview...")
}
}
.task {
do {
let request = MKLookAroundSceneRequest(coordinate: coordinate)
let fetchedScene = try await request.scene
scene = fetchedScene
} catch {
errorMessage = error.localizedDescription
print("Error loading Look Around scene: \(error)")
}
}
}
}
I really need some help. I have been going back and forth with a customer of mine for weeks. Our app is supposed to track location in the background after a user starts it in the foreground. Every time I test it, it works. I can put the app in the background and walk around for hours. Every time he tests it, it doesn't work. He puts the app into the background and about a minute later, it stops tracking him. Then it starts again when the app comes back to the foreground.
We have each tried it on two devices with the same results.
I'm willing to post the rest of the details if anyone is interested in helping me, but the last couple of times I got no response, so I'm not going to bother unless I can get some help this time. Thanks.
Issue Summary
After calling startRangingBeacons, the didRangeBeacons delegate method does not receive iBeacon scan data when the device display is turned off in the background.
Expected Behavior
On iOS 17.2.1 (iPhone 14), beacon ranging continues in the background even when the display is turned off. The same behavior is expected on iOS 18, but it is not working as intended.
Observed Behavior
On iOS 18, once the display turns off, beacon ranging stops, and the didRangeBeacons method is not triggered until the display is turned back on.
• Location permission is set to “Always Allow.”
• Background Modes are correctly configured (Location Updates enabled).
Steps to Reproduce
Ensure location permission is set to Always Allow.
Enable Background Modes → Location Updates in Xcode settings.
Call startRangingBeacons(in:) in the app.
Put the app in the background and turn off the display.
Observe that didRangeBeacons is not triggered while the display is off.
Additional Notes
• The issue does not occur on iOS 17.2.1 (iPhone 14), where beacon ranging continues even with the display off.
• This behavior change is observed on iOS 18 across multiple devices.
Could you confirm if this is an intended change in behavior or a bug? If this is expected behavior, what alternative approach is recommended to maintain continuous beacon ranging when the display is off in the background?
I’m facing an issue with iOS that I hope someone can help with. I developed an app a few years ago that records GPS tracks. Up until recently, everything worked fine—even when the app was running in the background, the recording continued without problems.
However, since releasing an update compiled after the iOS 18 release, users have reported that background tracking no longer works. I’ve reviewed the iOS documentation but haven’t found any relevant changes or solutions. Before the newly compiled release the app was working well on iOS 18 devices as well.
Some users have reported that switching to the location permission from "When Using the App" to "Always" solved the issue. This is not the case for all users.
Has anyone else encountered this issue? Any recommendations or insights on how to resolve it would be greatly appreciated.
Below you can see the code used for the location tracking. Before the issue happened the app was compiled with XCode 15.4. Now I am using XCode 16.2
locationManager.activityType = CLActivityType.fitness
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = 3
locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = false
if #available(iOS 11.0, *) {
locationManager.showsBackgroundLocationIndicator = true
}
locationManager.startUpdatingLocation()
if #available(iOS 17.0, *) {
// Create a CLBackgroundActivitySession object
backgroundActivitySession = CLBackgroundActivitySession()
}
Thanks in advance for your help!
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.
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!
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.
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)"
Could anybody give me an example how to set the „NSLocationRequireExplicitServiceSession“ in the info.plist correctly?
Thank you
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.
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
I'm following:
https://developer.apple.com/documentation/applemapsserverapi/creating-a-maps-identifier-and-a-private-key#Create-a-Maps-ID
to create map id and private key. On step #4 I can't find "Maps IDs checkbox" on the web page, **** is the screen capture which contains all options I have on my page:
我目前在做一个防止设备使用的位置是虚拟的,目前通过苹果的api无法直接判断位置来源于真实或虚拟。请问我该如何去判断它呢?
Does anyone know how long it usually takes for us to hear back from Apple regarding a request for Location Push Service Extension entitlement?