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

Posts under Maps & Location subtopic

Post

Replies

Boosts

Views

Activity

Constraining Beacon with CLBeaconIdentityCondition
In reference to this webpage, I'm turning my iPad to an iBeacon device. class BeaconViewModel: NSObject, ObservableObject, CBPeripheralManagerDelegate { private var peripheralManager: CBPeripheralManager? private var beaconRegion: CLBeaconRegion? private var beaconIdentityConstraint: CLBeaconIdentityConstraint? //private var beaconCondition: CLBeaconIdentityCondition? override init() { super.init() if let uuid = UUID(uuidString: "abc") { beaconIdentityConstraint = CLBeaconIdentityConstraint(uuid: uuid, major: 123, minor: 456) beaconRegion = CLBeaconRegion(beaconIdentityConstraint: beaconIdentityConstraint!, identifier: "com.example.myDeviceRegion") peripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) } } func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { switch peripheral.state { case .poweredOn: startAdvertise() case .poweredOff: peripheralManager?.stopAdvertising() default: break } } func startAdvertise() { guard let beaconRegion = beaconRegion else { return } let peripheralData = beaconRegion.peripheralData(withMeasuredPower: nil) peripheralManager?.startAdvertising(((peripheralData as NSDictionary) as! [String: Any])) } func stopAdvertise() { peripheralManager?.stopAdvertising() } } In Line 10, I'm using CLBeaconidentityConstraint to constrain the beacon. Xcode says that this class is deprecated and suggests that we use CLBeaconIdentityCondition. But if I try to use it, Xcode says Cannot find type 'CLBeaconIdentityCondition' in scope I've just updated Xcode to 16.4. I still get the same error. So how do we use CLBeaconIdentityCondition to constrain the beacon? My macOS version is Sequoia 15.5. Thanks.
2
0
121
Jun ’25
Background Modes Capability Missing in App ID Configuration
Hello, I upgraded my Apple Developer account from free to paid (Individual), but I cannot enable “Background Modes” (specifically “Location updates”) for any of my App IDs—including both old App IDs created while on the free account and brand new App IDs created after upgrading. When I go to Apple Developer Portal > Identifiers > [select App ID] > Edit, the option for “Background Modes” is missing from the list of capabilities. This is preventing me from enabling required entitlements for background location in Xcode, and all provisioning profiles fail with errors such as: Provisioning profile "iOS Team Provisioning Profile: [my bundle id]" doesn't include the com.apple.developer.location.always and com.apple.developer.location.background entitlements. Steps I’ve Taken: Upgraded to a paid Apple Developer Program (verified in my account). Created new App IDs after upgrading—Background Modes is still missing. Created new Xcode projects with new App IDs and bundle identifiers—same result. Refreshed provisioning profiles, cleaned Xcode, logged out/in—no change. Contacted Apple Support; advised to file a Code-Level Support request, but the issue is with the portal/App ID capabilities, not my code. My Question: Has anyone experienced this issue where Background Modes capability is missing for all App IDs, even after upgrading to a paid account? Is there any workaround, or does this require intervention from Apple Developer Support to “unlock” the missing capabilities for my developer account? Any insight or advice would be appreciated! Thank you.
6
0
199
Jun ’25
Are rate limits for calculate, calculateETA, and reverse geocoding shared across an app?
Hi, I'm using MapKit's MKDirections.calculate, calculateETA, and reverse geocoding (via CLGeocoder.reverseGeocodeLocation) in my iOS app. I understand that there are undocumented rate limits for these services to prevent abuse, but I couldn't find official details. I would like to know: Are the rate limits applied per device, per app installation, or are they shared across all users of the same app bundle ID? Is there any guidance on how to design these features to avoid hitting rate limits in a production environment? What is the best practice if a user repeatedly triggers routing or reverse geocoding (e.g., typing or moving the map)? Any clarification or official documentation would be greatly appreciated. Thank you!
1
1
99
Jun ’25
XCFramework Location Behavior Differs from Standalone App in Background/Sleep Mode
Hi Apple Dev Team & Community, We’ve encountered an issue with background location updates when using an XCFramework we’ve built from our main app. Context: We have a standalone app called TravelSafely that reliably performs background location updates and alerts, even during sleep mode. From this app, we extracted some core functionality into an XCFramework, including location management, and provided it as an SDK to a client. We created a demo app to test this SDK in isolation. Problem: In the demo app, we notice that location updates work fine in the foreground. However, in the background or sleep mode, location updates sometimes stop completely. When we bring the app to the foreground again, location resumes. This does not happen in the original standalone app. What We’ve Already Checked: UIBackgroundModes includes location Info.plist has the required permissions Location is started correctly using startUpdatingLocation We maintain strong references and use background tasks as needed Question: Why would an app using a binary XCFramework (with location logic) behave differently from the original app in terms of background execution? Is there any known issue or recommendation when working with SDKs/XCFrameworks that need to manage background tasks and location updates? Any insights or recommendations to maintain proper background behavior would be highly appreciated. Thank you!
10
0
81
Jun ’25
Location updates in background…
Hello, I’ve done a lot of testing of location services running in background with various settings, but in all scenarios location updates pause after a couple of hours, especially overnight In sleep mode. My app, for personal safety, requires regular location updates to 5m accuracy every minute. The only solution I have found is to keep the app in foreground. Location always stops updating. Background mode stops updating. Live location services stops updating. Is there a solution I may have missed other than keeping app in foreground? thank you, Brendan
1
0
58
Jun ’25
CLLocationManager not opening terminated app in background when user terminated app.
We have background location updates enabled in our app that updates the location on our servers to deliver realtime weather alerts. We see that we are receiving these location updates when the app is backgrounded by the user. However, when the user removes our app from the background using the App Switcher, we no longer see notifications happening. We have the app delegate's "didFinishLaunchingWithOptions" method setup to check for .location in the launch options, and start location tracking immediately. Is it the intention of the OS to no longer send our app background location updates if the user manually removes our app from the background?
2
0
73
Jun ’25
Simulator location data
I’ve just updated to Simulator 16.0 (104.1) I’m currently developing my first app, which relies heavily on location data. It was simulating correctly before I updated Simulator. Since the update it is no longer receiving location data. Is anyone else experiencing this problem?
1
0
121
May ’25
React-native-map. LongPress callback not working
Summary The onLongPress callback on MapViewcomponent is not working on iOS devices. The callback is properly implemented but never gets triggered on iOS, while it works as expected on Android. Reproducible sample code <MapView onLongPress={(e) => { console.log("onLongPress", e); setAddLocation(e.nativeEvent.coordinate); }} // ... other props Steps to reproduce Just put onLongPress callback on MapView and notice it won't be triggered. Expected result Long press on the map should trigger the onLongPress callback The callback should receive the event object with coordinates Actual result Long press on the map does not trigger the callback on iOS No console logs are shown when long pressing The functionality works as expected on Android React Native Maps Version 1.23.8 What platforms are you seeing the problem on? iOS (Apple Maps) React Native Version 0.79.2 What version of Expo are you using? SDK 53 Device(s) Any iOS Device
0
0
51
May ’25
CLLocationUpdates stops when user sleeps
I am using CLLocationUpdate.liveUpdates() to build a location sharing app. Most of the time it works fine, including in the background, giving acceptably frequent updates. However, soon after the user puts their phone away for the night, the updates stop coming. I've checked all the instance properties (.stationary, .locationUnavailable, etc.) but none of them are ever set to true, even for the last update before updates end. Is there some way to keep the updates coming through the night? I've included some relevant parts of my code here: func startLocationUpdates() { if self.manager.authorizationStatus == .notDetermined { self.manager.requestWhenInUseAuthorization() } Task { do { self.background = CLBackgroundActivitySession() self.session = CLServiceSession(authorization: CLServiceSession.AuthorizationRequirement.always) let updates = CLLocationUpdate.liveUpdates() for try await update in updates { if let loc = update.location { BackgroundServiceKt.onLocationUpdate(arg: loc) } // check all the instance properties } } catch { // error } return } } class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { LocationsHandler.shared.startLocationUpdates() return true } }
0
0
84
May ’25
[iOS] Location data no longer updating consistently after updating the app from old version
I am developing an iOS app that uses CLLocationManager to collect location continuously in both foreground and background. But it has the following 4 issues and I don’t understand why: After a while of not using the app, I can not get location updates regularly. Even after that, I go into the app more often or even turn OFF and turn ON the permission again, but the problem still doesn’t improve until I reinstall the app. Previously, I used SilentLog SDK to collect location. Since the cost was quite high, we developed our own SDK that also handles location tracking. After updating the app from the old version using SilentLog SDK to the new version using my own SDK, I can not get location updates regularly. However, when I reinstalled the app, it worked perfectly. It seems that apps downloaded from TestFlight can get location more continuously than apps downloaded from the App Store We sometimes encounter this error in the logs: Error Domain=kCLErrorDomain Code=0 “(null)” I think my app was not terminated in the background because I still collect location but it is not as frequent. I want to know if Apple has any mechanism to prevent such apps from getting location data continuously? I use CLLocationManager with the following configuration: self.locationManager.distanceFilter = 20 self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager.allowsBackgroundLocationUpdates = true self.locationManager.showsBackgroundLocationIndicator = false self.locationManager.pausesLocationUpdatesAutomatically = false I also filter the location updates using: guard let location = locations.last else { return } guard location.horizontalAccuracy <= 100 else { return } guard location.speedAccuracy >= 0 else { return } I use a background task to wake up the device every 15 minutes, and I also use silent push notifications in a similar manner. Each time the task is executed, I usually call stopLocation and then startLocation again. This happens quite frequently — will it have any impact or cause any issues?
0
0
86
May ’25
Apple Maps URL scheme daddr=lat,long no longer working – regression?
Hello, I'm experiencing an issue with the Apple Maps URL scheme when using raw latitude and longitude coordinates in the daddr parameter. Until recently, using a URL like this worked reliably: https://maps.apple.com/?daddr=37.7749,-122.4194 This would open Apple Maps and show directions from the current location to the specified coordinates. However, on recent iOS versions, this URL no longer behaves as expected.
1
0
70
May ’25
kCLErrorLocationUnknown becoming a big issue
In the last few months we have seen a lot of the following errors in which it fails to retrieve location information. This seems to happen across multiple browsers and feels related to apple/mac OS more than the browsers. Error: "CoreLocationProvider: CoreLocation framework reported a kCLErrorLocationUnknown failure." Any suggestions or an ETA on when this can be fixed? I have seen other threads/posts on this but wanted a new one to highlight the issue is prevalent.
2
0
473
May ’25
Background location indicator stuck in dynamic island when using CLServiceSession and CLBackgroundActivitySession
We have a setup that's really close to the one used in the example project - Monitoring location changes with Core Location. In short, we have a flag that indicates whether or not we should start background location monitoring. If the flag is on, after the app starts, we Create a CLServiceSession with authorization: .always Create a CLBackgroundActivitySession The user can perform an action (press a button) to toggle the flag off, in which case we invalidate and dispose of the CLServiceSession and CLBackgroundActivitySession instances and cancel any liveUpdates observation. So far, so good, everything works as expected. However, we're experiencing a weird behavior on iPhones with Dynamic Island after there's an app update. When the user is on the same app version, the behavior is correct. have the flag on, background location monitoring works fine, when the app is in the the background, there's correctly a location indicator in Dynamic Island the user can go back to the app and turn the flag off (disposing of instances, cancelling location observation), and when the app is in the background, there is no location indicator in Dynamic Island The problem arises when the user updates the app open version 1.0 of the app have the flag on, background location monitoring works fine, when the app is in the the background, there's correctly a location indicator in Dynamic Island download an app update - version 2.0 the app restarts, didFinishLaunchingWithOptions gets called again and we start the background services dynamic island indicator is correctly showing a location indicator the user goes into the app, toggles the flag off - turning location observation off, we dispose of everything now, when the app is moved to the background, there's still a location indicator in the Dynamic Island, even though we're no longer observing location The indicator is hard to get rid of, there are only 2 ways we've found restart the device, or uninstall the app The question is - is this a bug in the system? Or is there anything we should be doing actively after an app update? Thank you!
1
1
69
May ’25
Symbol not found: _$sSo22CLLocationCoordinate2DVSE12CoreLocationMc when building for visionOS 2.5 with Xcode 16.3
Hello, I'm encountering a runtime crash when building my visionOS app with Xcode 16.3 for visionOS 2.5. Our existing AppStore/Testflight app is also instantly crashing on visionOS 2.5 when opened but works fine on e.g visionOS 2.4. The app builds successfully but crashes on launch with this symbol lookup error (slightly adjusted because the forum complained regarding sensitive data): Symbol not found: _$sSo22CLLocationCoordinate2DVSE12CoreLocationMc Referenced from: <XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX> /private/var/containers/Bundle/Application/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/MyApp.app/MyApp.debug.dylib Expected in: <XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX> /usr/lib/swift/libswiftCoreLocation.dylib dyld config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/usr/lib/libLogRedirect.dylib:/usr/lib/libBacktraceRecording.dylib:/usr/lib/libMainThreadChecker.dylib:/System/Library/PrivateFrameworks/GPUToolsCapture.framework/GPUToolsCapture:/usr/lib/libViewDebuggerSupport.dylib I've already implemented my own Codable conformance for CLLocationCoordinate2D: extension CLLocationCoordinate2D: Codable { // implementation details... } This worked fine on previous visionOS/Xcode versions. Has anyone encountered this issue or found a solution? System details: macOS version: 15.3.2 Xcode version: 16.3 visionOS target: 2.5 Thank you!
2
0
61
May ’25
How can I prevent virtual location from affecting the security of my app
Hello, I have noticed that some users have modified their real location through an app called "MGU" to bypass my app's security checks. I want to know how to protect my app and detect users using virtual location. I have reproduced the process of virtual positioning here: Insert a plug-in through the interface at the bottom of the phone and connect it via Bluetooth on the phone Set the desired positioning target on the "MGU" app Turn off your phone's WiFi, network, and location for 10 seconds, then turn it back on At this point, virtual positioning is successful. Please assist me in troubleshooting this issue and inform me of the principle of implementing virtual positioning in this app and how to prevent it. The following is the screen recording of virtual positioning operation: https://flowus.cn/share/145b3232-26c3-4ea3-b3ff-4aad1495eb4d
1
0
61
Apr ’25
Polyline rendering below street labels in MapKitJS
Hello (: I’m working with MapKitJS and would like to render polylines that follow roads — similar to the behavior seen on maps.apple.com. While I can align polylines to roads manually, I haven’t found a way to render them below street names and road shields. Currently, all polylines appear above labels, which reduces readability when displaying routes in urban areas. On maps.apple.com, polylines are rendered under street labels, which provides a much cleaner appearance. Is there a way to achieve this layering behavior in MapKitJS? If not, are there plans to support this kind of layer control in the future? Thanks in advance! MapKitJS (5.45.0): maps.apple.com:
2
0
52
Apr ’25