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?
Maps & Location
RSS for tagLearn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello,
Is it possible to retrieve URLs (the URL associated for the specified location) for the Place object when you query the Apple Maps Server APIs? They are available when you make a MKLocalSearch.Request() directly in Swift. We have both iOS and Android apps, and it's not currently possible to get the URLs on Android.
Thanks!
Hi everyone!
I’m a new developer diving into my first Apple Watch project, and I’m really excited to get started! This app relies heavily on using the most precise location data possible.
Could anyone point me to some official documentation or helpful resources on how to achieve high-accuracy location tracking specifically for watchOS? Any tips or best practices would also be greatly appreciated!
Thanks in advance for your help!
Description of the Bug:
Core Location intermittently reports inaccurate location updates, albeit with a high accuracy value. This problem occurs almost exclusively while travelling in metros underground affecting the ability to rely on the framework effectively.
Steps to Reproduce:
The user starts travelling on ground level at point A
The user continues travelling and, after some time, is now underground at point B. A stationary beacon scanned at point B confirms this.
Core Location is observed to deliver a location update with a high-accuracy value but with the coordinates around point A when the user is actually around point B.
Expected Behaviour:
Accurate locations should be delivered at all times. In other words, Core Location should not report location updates with high accuracy when its certainty is low.
We have an application. We are monitoring the fence event. We are using 'startMonitoringForRegion' API. but we are not getting any fence event.
Steps
Create a fence using 'startMonitoringForRegion' API BG on APNS trigger.
initial fence state 'didDetermineState' not received.
From Syslogs we can see OS has detected but event is not given to Application
We are compiling code using SDK18.0
Error **
locationd Fence: LAC monitoring is not sufficient for /
ocationd Fence: no allowing wifi monitor for, 400.0, fence
Feedback Ticket ID: FB17250308
Syslogs Snippet:
debug 2025-04-15 12:45:40.890193 -0500 locationd FenceCal: combine non-fine non-large fence, distance, 0.0, /
//OS detetected fence state
default 2025-04-15 12:45:44.706232 -0500 locationd Fence: fenceUpdate, , bundle, , type, GPS , loc, 33.1171776, -96.6606076, acc, 19, distance, 17, tech, LC...+, trans, 0, state, 0, cont, 1, fence, 33.11728835, -96.66048288, 1011.0, 766431742.6, sCount, 0, 0, trig, 0, 3, sinceLastLoc, 10.0, events, 0x00001810, status, (Inside) => (Inside) , settled state, (Unknown) ==> (Unknown), cantShiftButNeedTo, 0, sinceLastTransition, -1.0, significant, 0, loi, 0, lastProximityStateTimestamp, -1.000000, lastProximityState, 0, lastApproachingState, 0
//
debug 2025-04-15 12:45:44.706247 -0500 locationd Fence: LAC monitoring is not sufficient for /
//
debug 2025-04-15 12:45:44.706263 -0500 locationd Fence: no allowing wifi monitor for, 400.0, fence, Fence, []//, latitude, 33.11728835, longitude, -96.66048288, refFrame, 0, distance, 1011.0, eFistance, 1011.0, lDown, -1.0, time, 766431742.6, ctime, -1.0, flags, EX------, key, -1506186373, throttled, N, polygon, 0, envType, 2, locType, 0
I have a marine navigation app which displays GPS quality information when receiving NMEA message from an external GPS. These include the number of satellites and Horizontal Dilution of Precision (HDOP).
As far as I can see, the only additional information available through location services (for devices with built in GPS) is horizontal and vertical accuracy.
Am I missing anything? Also does anyone know how horizontal accuracy is derived from HDOP?
When I try to import mapkitjs using HTML, I use the correct token, but the error token is invalid.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>地点信息查询</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f7;
}
.container {
max-width: 800px;
margin: 0 auto;
}
.search-box {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 8px;
font-size: 16px;
}
.result-container {
background: white;
padding: 20px;
border-radius: 12px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.place-image {
width: 100%;
max-height: 300px;
object-fit: cover;
border-radius: 8px;
margin-bottom: 15px;
}
.place-info {
margin-top: 15px;
}
.place-info h2 {
margin-top: 0;
color: #1d1d1f;
}
.info-item {
margin: 10px 0;
color: #515154;
}
#map {
width: 100%;
height: 300px;
border-radius: 8px;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>地点信息查询</h1>
<input type="text" id="searchInput" class="search-box" placeholder="请输入地点名称(如:北京故宫)">
<div class="result-container">
<div id="placeImage"></div>
<div class="place-info">
<h2 id="placeName"></h2>
<div id="placeDetails"></div>
</div>
<div id="map"></div>
</div>
</div>
<script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script>
<script>
// 初始化 MapKit
mapkit.init({
authorizationCallback: function(done) {
done('mytoken');
},
language: 'zh-CN',
region: 'CN',
callback: function(error) {
if (error) {
console.error('MapKit 初始化错误:', error);
alert('地图服务初始化失败,请检查网络连接和授权设置');
} else {
console.log('MapKit 初始化成功');
}
}
});
// 添加错误处理
window.addEventListener('error', function(event) {
console.error('MapKit 错误:', event.error);
});
const searchInput = document.getElementById('searchInput');
const placeImage = document.getElementById('placeImage');
const placeName = document.getElementById('placeName');
const placeDetails = document.getElementById('placeDetails');
const mapDiv = document.getElementById('map');
let map;
searchInput.addEventListener('input', debounce(searchPlace, 500));
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
async function searchPlace() {
console.log('搜索');
const query = searchInput.value;
if (!query) return;
try {
// 使用 MapKit 搜索地点
const search = new mapkit.Search({
region: new mapkit.CoordinateRegion(
new mapkit.Coordinate(39.9042, 116.4074), // 默认北京坐标
new mapkit.CoordinateSpan(0.1, 0.1)
)
});
search.search(query, (error, data) => {
if (error) {
console.error('搜索错误:', error);
return;
}
if (data.places.length > 0) {
const place = data.places[0];
displayPlaceInfo(place);
showMap(place);
}
});
} catch (error) {
console.error('获取地点信息失败:', error);
}
}
function displayPlaceInfo(place) {
placeName.textContent = place.name;
let detailsHTML = '';
if (place.address) {
detailsHTML += `<p class="info-item">地址: ${place.address}</p>`;
}
if (place.phoneNumber) {
detailsHTML += `<p class="info-item">电话: ${place.phoneNumber}</p>`;
}
if (place.url) {
detailsHTML += `<p class="info-item">网址: <a href="${place.url}" target="_blank">${place.url}</a></p>`;
}
placeDetails.innerHTML = detailsHTML;
// 获取地点图片
if (place.pointOfInterestCategory) {
// 这里可以调用其他图片API来获取地点图片
// 示例使用占位图片
placeImage.innerHTML = `<img src="https://source.unsplash.com/800x400/?${encodeURIComponent(place.name)}" class="place-image" alt="${place.name}">`;
}
}
function showMap(place) {
if (map) {
map.remove();
}
map = new mapkit.Map(mapDiv, {
region: new mapkit.CoordinateRegion(
place.coordinate,
new mapkit.CoordinateSpan(0.01, 0.01)
)
});
const annotation = new mapkit.MarkerAnnotation(place.coordinate, {
title: place.name,
data: { place: place }
});
map.addAnnotation(annotation);
}
</script>
</body>
</html>
My app has been using MKLocalSearch.Request for keyword-based location searches, and it has worked smoothly for a long time. However, starting last Wednesday, I began receiving an error from MKLocalSearch.start: MKErrorDomain (error code 4).
This issue only occurs when the network environment is based in mainland China (where the API uses the Amap data source). When the network switches to other regions and other Apple Maps data source is used, the error does not occur.
Another complication is that the API doesn't always fail—certain keywords still work (for example, "Huawei").
Already filed a ticket in Feedback Assistant: https://feedbackassistant.apple.com/feedback/15544549
Having multiple issues with google maps via wireless apply car play.
1.: maps freezing
2.:The direction I’m heading seems to be off and searching some times
3.: The most annoying, the audio doesn’t work when I’m using google maps for a trip.
Topic:
App & System Services
SubTopic:
Maps & Location
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
I updated my phone 14 pro to ios 18 and I faced issue with GPS. it’s show me in next Country and after minutes or hours it’s moved to the correct location
how is it can fix it
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!
I need some clarification on what is supposed to happen if the "allowsBackgroundLocationUpdates" flag on CLLocationManager is set to true, and only the "While in Use" permission has been given.
The customer I'm working with thinks that this combination should allow the app to receive location updates in the background indefinitely, as long as the app was in the foreground when we started receiving them.
What we've experienced is inconsistent. App updates do continue when the screen locks and in some cases when we switch to another app, but often they do not.
Our app doesn't require location updates 24/7, it requires them for a period of time when the user is performing an activity. The user starts and stops the activity in the app, and the activity might last up to a couple of hours. Can we do this using "While in Use" or do we need to request "Always" ?
Topic:
App & System Services
SubTopic:
Maps & Location
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.
mapView.showsTraffic=true
mapView.showsScale=true
mapView.showsCompass=true
mapView.showsUserLocation=true
mapView.showsBuildings=true
mapView.showsLargeContentViewer=true
hi,guy,please help to see this problem,thankyou,the mapkit api support some showsfunction,but I can not find how to show the exit of subway in my own app,but the map app of appple shows the exit of the subway,so how can I show the exit of the subway stations by using mapkit
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?
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
Hi, I am working on a React Native app and i want to have a latitude longitude of a user in every 15 minutes and want to do something like an api call with it. I want to keep continuing this no matter my app is in background, foreground or in killed state. Is there any way or method through which i can achieve this natively or using React Native?
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?
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?