I am trying to retrieve delivered notifications using UNUserNotificationCenter.getDeliveredNotifications(completionHandler:), but I have encountered an issue:
Notifications triggered by UNTimeIntervalNotificationTrigger or UNCalendarNotificationTrigger appear in the delivered list.
However, notifications triggered by UNLocationNotificationTrigger do not appear in the list.
Here is the code I use to fetch delivered notifications:
UNUserNotificationCenter.current().getDeliveredNotifications { notifications in
for notification in notifications {
print("Received notification: \(notification.request.identifier)")
}
}
The notification is scheduled as follows:
let center = UNUserNotificationCenter.current()
let content = UNMutableNotificationContent()
content.title = "Test Notification"
content.body = "This is a location-based notification."
content.sound = .default
let coordinate = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194) // Example coordinates
let region = CLCircularRegion(center: coordinate, radius: 100, identifier: "TestRegion")
region.notifyOnEntry = true
region.notifyOnExit = false
let trigger = UNLocationNotificationTrigger(region: region, repeats: false)
let request = UNNotificationRequest(identifier: "LocationTest", content: content, trigger: trigger)
center.add(request) { error in
if let error = error {
print("Error adding notification: \(error.localizedDescription)")
}
}
Why does getDeliveredNotifications not return notifications that were triggered using UNLocationNotificationTrigger?
How can I retrieve such notifications after they have been delivered?
Core Location
RSS for tagObtain the geographic location and orientation of a device using Core Location.
Posts under Core Location tag
112 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I've been reading this question: https://developer.apple.com/forums/thread/701945 and watching the videos on background tasks
But can't arrive to a concrete solution.
Q1: Are there any tips (or sample app) on how to handle a launch in background in a streamlined way? How to have a shared code that is ran for both 'launch in background' & 'launch in foreground'?
Specifically the case I'm talking about is:
You set up some observance of some OS callback at a Foo screen of your app. Example app should request and then send push-to-start live activity tokens to server. Or setup location tracking.
App is then suspended and then later terminated but is eligible for relaunch
App is then launched in background because it has requested a push-to-start live activity token or an update for location tracking.
User DOES NOT go back to screen Foo.
So at this point app is no longer tracking / listening to updates for token update or location changes.
How should I architecture my code for this? I'm trying to see if there's a an approach where I can avoid having multiple places in code where I do the same thing. Currently what I'm doing is as such:
Q2: Is it then correct to say that anytime you've launched your app, whether it's in foreground or background then you must immediately match 'all observations done by the previous app launch'?
Like store items in UserDefaults and upon launch retrieve them and do:
handleGeneralAppLaunchFlow()
// ALSO
if defaults.contains("didLastLaunchSetupLiveActivtiyTokenObservance") {
for await ptsToken in Activity<EmojiRangers> .pushToStartTokenUpdates {
...
}
}
if defaults.contains("didLastLaunchSetupLocationTracking") {
locationManager = CLLocationManager()
locationManager?.delegate = itsDelegate
locationManager?.allowsBackgroundLocationUpdates = true
locationManager?.showsBackgroundLocationIndicator = true
locationManager?.startUpdatingLocation()
}
// Other checks for prior observance setup
Q3: Actually I think even if app is launched in foreground then because you may not end up at screen Foo again, then you must setup things regardless of app state and just based on prior observations set. Right?
Q4: And then later if the user ever made it again to screen Foo, then we just skip the re-do of the observance, or maybe to just keep things simple, we'd just redo without over-engineering things?
I tried to mark my questions with Q1- Q4.
I'm calling .startUpdatingLocation() from the background to detect user's location but the updates stop shortly after they start.
The issue seem to also be discussed here:
https://developer.apple.com/forums/thread/726945
I wonder if any solution has been found?
This is a critical feature for our app.
I have:
kCLLocationAccuracyBestForNavigation
allowsBackgroundLocationUpdates = true
pausesLocationUpdatesAutomatically = false
Location Updates in background modes
distanceFilter not set or kCLDistanceFilterNone
It seems like find my mac is able to fetch the device location even if the device is in locked state. Why can’t other apps do the same.
Apple Feedback Ticket: FB16804936
Background
We develop a parental control application called Adora Kids (https://apps.apple.com/us/app/adora-kids/id6443787669) that requires "Location Always" permission to function properly. Our app has Screen Time authorization and provides monitoring services for parents.
Issue
We are experiencing a recurring problem where child users receive the system notification "Adora accessed your location in the background" every few days. This frequently results in children disabling location permissions, which prevents our app from functioning as intended.
Current Approach and Limitations
We have explored using Content & Privacy Restrictions for Location Services as a potential solution, but have encountered two significant limitations:
These restrictions cannot be accessed programmatically via the ManagedSettings framework (unlike AppStoreSettings and other restrictions).
The current implementation is "all-or-nothing" - enabling location restrictions blocks permission changes for ALL apps on the device, preventing children from granting legitimate location access to other applications.
Questions
Is there a way to programmatically access and manage Content & Privacy Restrictions for Location Services through the ManagedSettings framework that we might have overlooked?
Are there any recommended approaches for apps with Screen Time authorization to prevent users from changing specific permissions (particularly location) while still allowing them to manage permissions for other apps?
Does Apple have plans to implement app-specific permission locking for apps with Screen Time authorization in future iOS releases?
Are there any alternative approaches or workarounds that other developers have successfully implemented for this use case?
Any guidance from the developer community or Apple engineers would be greatly appreciated. This is a critical functionality issue affecting the reliability of our parental control service.
Thank you in advance for your assistance.
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Core Location
Family Controls
Managed Settings
I am able to fetch the location in foreground and background.
I need just confirmation that can we get location apps killed state.
If It's possible then how can I do that.
I am able to get location in for ground and back ground but
Now I need to get location when user killed app.
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Watch Connectivity
watchOS
Core Location
Hello,
I’m experiencing an issue with my iOS app that uses CoreBluetooth in combination with beacon monitoring. My app is designed to wake via beacon region monitoring and then start scanning for a specific BLE peripheral (with specific service UUIDs). When the device screen is bright (i.e., the device is unlocked, or locked but the screen is active/bright), everything works perfectly—the connection is established and maintained without any issues in both: foreground and background.
However, when the device is left alone for a while and the lock-screen dims (sleeps), the app continues to run in the background and range the beacon (I can confirm this via realtime console logs), but the connection attempt fails. Here’s what I observe:
The central manager’s delegate method didConnect is called, indicating that the peripheral was connected.
Almost immediately afterward, didDisconnect is triggered with the error message:
"The specified device has disconnected from us.".
The interesting part is (I repeatedly see this error in the console, because the app repeatedly tries to connect to peripheral until a success), when I touch the lockscreen (not unlock, but just touch, which makes the screen to light up brighter), the connection is being established without any further issues!
I have the necessary background modes enabled in the app’s capabilities (e.g., bluetooth-central, location-always-mode, etc..). My expectation was that, thanks to beacon monitoring, the app would be awakened when needed, and scanning/connection would work reliably in the background regardless of whether the device is active or dimmed.
My questions are:
Why might the connection fail with this error when the device is locked/dimmed?
Is this behavior expected due to iOS power management policies even if the app remains active in the background?
Is there a way to ensure a reliable connection in such cases?
Any insights, workarounds, or suggestions would be greatly appreciated. Thank you in advance!
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Core Location
Background Tasks
Core Bluetooth
We have a PWA app developed by our company. In order to distribute this app to users' iPhones, we put this PWA app inside an XCode app. That means we put a WebView in XCode to display the PWA URL. Everything works perfect, except for location access.
The PWA app access the device location. When the first time the app acess location, it asks for user consent two times, by PWA app and by the XCode app. This is fine. When the user clicks Allow, the XCode app preserves the user choice and never asks again. However, the PWA app keeps on asking user permission every day. If we close the app open again, it will ask one more time. That means twice daily. But if we close and open the app for a third time, it will not ask. It remembers the user choice only for 24 hours.
If we install the PWA app directly in iPhone (that means if we add the URL as bookmark in home screen), it is asking for location permission only once. However, when we put this app inside an XCode app it is asking every day.
This affects the user experience, and as our users are not tech savvy, causing many issues. Is there a way to force the PWA app inside XCode app to remember the user choice?
Any help is very much appreciated.
Thanks,
After the implementation of liveUpdates(_:) to receive asynchronous sequence of location updates, we are receiving crash reports on a huge number of users.
However we cannot reproduce the crash so any help is much appreciated.
This is the stack trace:
com.apple.main-thread
0 libsystem_kernel.dylib 0xce4 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x439c mach_msg2_internal + 76
2 libsystem_kernel.dylib 0x42b8 mach_msg_overwrite + 428
3 libsystem_kernel.dylib 0x4100 mach_msg + 24
4 CoreFoundation 0x717b0 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x70e90 __CFRunLoopRun + 1208
6 CoreFoundation 0x957f0 CFRunLoopRunSpecific + 572
7 GraphicsServices 0x1190 GSEventRunModal + 168
8 UIKitCore 0x3ca158 -[UIApplication _run] + 816
9 UIKitCore 0x3c8388 UIApplicationMain + 336
10 atto 0x6a41a0 main + 25 (AppDelegate.swift:25)
11 ??? 0x1ac153a58 (Missing)
com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0xce4 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x439c mach_msg2_internal + 76
2 libsystem_kernel.dylib 0x42b8 mach_msg_overwrite + 428
3 libsystem_kernel.dylib 0x4100 mach_msg + 24
4 CoreFoundation 0x717b0 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x70e90 __CFRunLoopRun + 1208
6 CoreFoundation 0x957f0 CFRunLoopRunSpecific + 572
7 Foundation 0x74728 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
8 Foundation 0x73558 -[NSRunLoop(NSRunLoop) runUntilDate:] + 64
9 UIKitCore 0x4bd354 -[UIEventFetcher threadMain] + 424
10 Foundation 0x115f40 NSThread__start + 732
11 libsystem_pthread.dylib 0x1afc _pthread_start + 136
12 libsystem_pthread.dylib 0x1a04 thread_start + 8
com.google.firebase.crashlytics.MachExceptionServer
0 FirebaseCrashlytics 0x21c10 FIRCLSProcessRecordAllThreads + 184
1 FirebaseCrashlytics 0x21ff0 FIRCLSProcessRecordAllThreads + 1176
2 FirebaseCrashlytics 0x18e74 FIRCLSHandler + 48
3 FirebaseCrashlytics 0x1b804 FIRCLSMachExceptionServer + 688
4 libsystem_pthread.dylib 0x1afc _pthread_start + 136
5 libsystem_pthread.dylib 0x1a04 thread_start + 8
com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0xce4 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x439c mach_msg2_internal + 76
2 libsystem_kernel.dylib 0x42b8 mach_msg_overwrite + 428
3 libsystem_kernel.dylib 0x4100 mach_msg + 24
4 CoreFoundation 0x717b0 __CFRunLoopServiceMachPort + 160
5 CoreFoundation 0x70e90 __CFRunLoopRun + 1208
6 CoreFoundation 0x957f0 CFRunLoopRunSpecific + 572
7 CFNetwork 0xeba68 +[__CFN_CoreSchedulingSetRunnable _run:] + 416
8 Foundation 0x115f40 NSThread__start + 732
9 libsystem_pthread.dylib 0x1afc _pthread_start + 136
10 libsystem_pthread.dylib 0x1a04 thread_start + 8
Thread
0 libsystem_kernel.dylib 0xa90 __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x46ac _pthread_wqthread + 368
2 libsystem_pthread.dylib 0x19f8 start_wqthread + 8
Crashed: com.apple.corelocation.shared
0 libobjc.A.dylib 0x2050 objc_release_x8 + 16
1 libsystem_blocks.dylib 0x1d30 bool HelperBase::disposeCapture<(HelperBase::BlockCaptureKind)3>(unsigned int, unsigned char*) + 68
2 libsystem_blocks.dylib 0x16a8 HelperBase::destroyBlock(Block_layout*, bool, unsigned char*) + 116
3 libsystem_blocks.dylib 0x1180 _call_dispose_helpers_excp + 72
4 libsystem_blocks.dylib 0x111c _Block_release + 236
5 libsystem_blocks.dylib 0xff4 bool HelperBase::disposeCapture<(HelperBase::BlockCaptureKind)4>(unsigned int, unsigned char*) + 68
6 libsystem_blocks.dylib 0x16f8 HelperBase::destroyBlock(Block_layout*, bool, unsigned char*) + 196
7 libsystem_blocks.dylib 0x1180 _call_dispose_helpers_excp + 72
8 libsystem_blocks.dylib 0x111c _Block_release + 236
9 libdispatch.dylib 0x1b4f8 _dispatch_client_callout + 16
10 libdispatch.dylib 0xa2cc _dispatch_lane_serial_drain + 736
11 libdispatch.dylib 0xad90 _dispatch_lane_invoke + 380
12 libdispatch.dylib 0x15178 _dispatch_root_queue_drain_deferred_wlh + 292
13 libdispatch.dylib 0x149fc _dispatch_workloop_worker_thread + 540
14 libsystem_pthread.dylib 0x4660 _pthread_wqthread + 292
15 libsystem_pthread.dylib 0x19f8 start_wqthread + 8
Thread
0 libsystem_pthread.dylib 0x19f0 start_wqthread + 142
Thread
0 libsystem_pthread.dylib 0x19f0 start_wqthread + 142
Thread
0 libsystem_pthread.dylib 0x19f0 start_wqthread + 142
So far, we have been using Google Maps to determine distance along a certain route for a MacOS app to register kilometers for a business administration app. But, this is no longer possible, as the login for google maps no longer works. I understand we would have to pay to continue using the Google Maps service as it was and we would have to make changes to the app. That would be ok, but I was just wondering does any developer on this forum have suggestions on how to resolve this issue? Or even maybe have suggestions, to make this work better than before. Three suggestions by chatgpt: use ANWB route planner using google maps, Pro6pp, or to useWisp.Software (something I haven't heard of before. Your suggestions and ideas are welcome. Also, if the Apple Developer team knows of a way how to do this in your app, your advice is more than welcome. Have a nice day!
Topic:
Developer Tools & Services
SubTopic:
Apple Developer Program
Tags:
Nearby Interaction
macOS
MapKit JS
Core Location
I want a solution to keep tracking the user once he started in driving state until parking.
I tried many solutions like use significant location changes, and silent push notifications and background tasks, but no one of them worked as expected.
I need when user started in driving the app be active until the user parked his car.
I'm using CoreMotion and CoreLocation.
The challenge is when the app is not active like killed or suspended.
So, how to do this? is this possible or not?
I want to create automations when the first person comes Home.
When Setting up the Automation on the owner device everything seems to be correct. Yet the Automation doesn‘t Wort properly. my girlfriend is listed as admin.
when she has a Look at the Automation, the Location of my phone is unknown.
the issue is that this leads To the following behaviour. When i come House the Automation Checks if my girlfriend is Home. All Good. When my Grilfriend comes Home the Automation doesn‘t Check where i am But directly execut the Automation.
Hello everyone,
I'm encountering a strange location authorization issue in the iOS simulator, and I'm hoping someone can help me analyze it.
Problem Description:
When my app runs for the first time in the simulator, it requests location permissions.
I select "Deny" for the authorization.
Then, I go to the simulator's "Settings" -> "Privacy & Security" -> "Location Services" and enable location permissions for my app.
However, when I return to the app, CLLocationManager.authorizationStatus still returns .notDetermined, and the authorization request pop-up does not appear again.
This issue persists even after resetting the simulator settings multiple times.
import CoreLocation
@Observable
final class LocationManager: NSObject, CLLocationManagerDelegate {
var locationManager = CLLocationManager()
var currentLocation: CLLocationCoordinate2D?
override init() {
super.init()
locationManager.delegate = self
}
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
let status = manager.authorizationStatus
print("Authorize Status: \(status)")
switch status {
case .authorizedWhenInUse, .authorizedAlways:
locationManager.startUpdatingLocation()
case .denied, .restricted:
stopLocation()
case .notDetermined:
locationManager.requestWhenInUseAuthorization()
print("Location permission not determined.")
@unknown default:
break
}
}
func requestLocation() {
let status = locationManager.authorizationStatus
if status == .authorizedWhenInUse || status == .authorizedAlways {
locationManager.requestLocation()
} else {
locationManager.requestWhenInUseAuthorization()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let newLocation = locations.first else { return }
currentLocation = newLocation.coordinate
print("Updated location: \(newLocation.coordinate)")
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("Location update failed with error: \(error.localizedDescription)")
currentLocation = nil
}
func stopLocation() {
locationManager.stopUpdatingLocation()
print("Stopped updating location")
}
}
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Core Location
Maps and Location
Simulator
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.
I'm working on an in-house iOS app designed to help users accurately track their routes during trips. Currently, I've implemented a method to track users when the app is open in the background. However, I'm facing challenges, as the tracking stops when the device is locked for more than 10 minutes.
I'm looking for a solution to continuously track a user's geolocation, even if the app is closed or not in use. Specifically, I want to ensure uninterrupted tracking, especially when the device is locked.
Here are some key points:
Current Method: I'm currently using the Core Location method and a combination of background tasks and a repeating timer to fetch the user's location and update a log for geolocation tracking when the app is open in the background.
Issues Faced: The tracking stops when the device is locked for more than 10 minutes. This limitation impacts the accuracy of the route tracking during longer trips.
Objective: My goal is to achieve continuous geolocation tracking, even when the app is closed or not actively used, to provide users with a seamless and accurate record of their routes.
Platform: The app is developed for iOS using the .net maui platform, and I'm seeking solutions or suggestions that are compatible with the iOS .net maui environment.
If anyone has experience or insights into achieving continuous geolocation tracking on iOS, especially when the app is not in use or the device is locked, I would greatly appreciate the assistance.
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Core Location
Background Tasks
Maps and Location
Hello everyone,
I'm working on a SwiftUI app that requires location services, and I've implemented a LocationManager class to handle location updates and permissions. However, I'm facing an issue where the location permission popup does not appear when the app is launched.
Here is my current implementation:
LocationManager.swift:
import CoreLocation
import SwiftUI
class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
private let locationManager = CLLocationManager()
@Published var userLocation: CLLocation?
@Published var isAuthorized = false
@Published var authorizationStatus: CLAuthorizationStatus = .notDetermined
override init() {
super.init()
locationManager.delegate = self
checkAuthorizationStatus()
}
func startLocationUpdates() {
locationManager.startUpdatingLocation()
}
func stopLocationUpdates() {
locationManager.stopUpdatingLocation()
}
func requestLocationAuthorization() {
print("Requesting location authorization")
DispatchQueue.main.async {
self.locationManager.requestWhenInUseAuthorization()
}
}
private func checkAuthorizationStatus() {
print("Checking authorization status")
authorizationStatus = locationManager.authorizationStatus
print("Initial authorization status: \(authorizationStatus.rawValue)")
handleAuthorizationStatus(authorizationStatus)
}
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
print("Authorization status changed")
authorizationStatus = manager.authorizationStatus
print("New authorization status: \(authorizationStatus.rawValue)")
handleAuthorizationStatus(authorizationStatus)
}
private func handleAuthorizationStatus(_ status: CLAuthorizationStatus) {
switch status {
case .authorizedAlways, .authorizedWhenInUse:
DispatchQueue.main.async {
self.isAuthorized = true
self.startLocationUpdates()
}
case .notDetermined:
requestLocationAuthorization()
case .denied, .restricted:
DispatchQueue.main.async {
self.isAuthorized = false
self.stopLocationUpdates()
print("Location access denied or restricted")
}
@unknown default:
DispatchQueue.main.async {
self.isAuthorized = false
self.stopLocationUpdates()
}
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
DispatchQueue.main.async {
self.userLocation = locations.last
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("Location manager error: \(error.localizedDescription)")
}
}
MapzinApp.swift:
@main
struct MapzinApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
@StateObject private var locationManager = LocationManager()
var body: some Scene {
WindowGroup {
Group {
if locationManager.authorizationStatus == .notDetermined {
Text("Determining location authorization status...")
} else if locationManager.isAuthorized {
CoordinatorView()
.environmentObject(locationManager)
} else {
Text("Location access is required to use this app. Please enable it in Settings.")
}
}
}
}
}
Log input:
Checking authorization status
Initial authorization status: 0
Requesting location authorization
Authorization status changed
New authorization status: 0
Requesting location authorization
Despite calling requestWhenInUseAuthorization() when the authorization status is .notDetermined, the permission popup never appears. Here are the specific steps I have taken:
Checked the Info.plist to ensure the necessary keys for location usage are present:
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
Verified that the app's target settings include location services capabilities.
Tested on a real device to ensure it's not a simulator issue.
I'm not sure what I might be missing. Any advice or suggestions to resolve this issue would be greatly appreciated. Thank you!
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?