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,
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
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
Hello,
I write a Bachelor-Theses about Geolocation on an iPhone. I have a Signal-generator from R&S to simulate GPS-Data. I write an App on an Android-Phone and can readout the GPS-ID and the strength from the signal and the time and Position for Geolocation zb. Island or Africa like this.
Now my thesis is about the iPhone and I write an App for get the location manager Geolocation and to save it to a sqlite-database with longitude, latitude and time.
But the App recognizes only the real world for geolocation on GPS (LTE and Wlan are disabled!). With my Radio-Generator it would not recognize any Geolocation like the Android phone.?
So I need some fast help for my thesis, where are my problems?
I allready have a function like this:
func updateAccuracy(highAccuracy: Bool) {
locationManager.desiredAccuracy = highAccuracy ? kCLLocationAccuracyBestForNavigation : kCLLocationAccuracyHundredMeters
print("🎯 GPS-Genauigkeit geändert: (highAccuracy ? "Hoch" : "Plane-Genauigkeit")")
}
but nothing happens?
Best regards
Topic:
App & System Services
SubTopic:
Maps & Location
I recently converted over my map from Mapbox Maps to MapKit Map. I have been able to add my polygons on the Map using MapPolygon. The issue I am having is being able to select the Polygon to be able to view information about the polygon.
Has anyone been able to figure out a way to tap on the Polygon? I have tried selection but the Polygon doesn't recognize the tap. I would really appreciate it if anyone could point me in the right direction of how I can accomplish this.
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?
First of all, my English skills are not good, so I wrote an AI program and sent it to complete the questions. sorry.
I'm developing a safety monitoring application that requires continuous BLE scanning for temperature and humidity sensors. I need clarification on the technical feasibility of background and sleep mode operation.
Key Requirements:
Continuous monitoring of BLE advertisements from temperature/humidity sensors
Must detect critical temperature/humidity changes immediately
Data logging every minute
Includes navigation features showing routes
Technical Questions:
Background Mode Operation
If using background modes (bluetooth-central + location):
Can we receive BLE advertisements reliably?
What is the actual scanning interval limitation?
Will CBCentralManagerScanOptionAllowDuplicatesKey limitation affect critical monitoring?
Sleep Mode Operation
Can the app maintain BLE scanning during device sleep?
Would combining with navigation background mode help?
Are there any recommended approaches for continuous monitoring?
Sample Code of Current Approach:
let options: [String: Any] = [
CBCentralManagerOptionShowPowerAlertKey: true,
CBCentralManagerOptionRestoreIdentifierKey: "uniqueIdentifier"
]
centralManager = CBCentralManager(delegate: self, queue: nil, options: options)
// Scanning setup
centralManager.scanForPeripherals(
withServices: [serviceUUID],
options: [CBCentralManagerScanOptionAllowDuplicatesKey: true]
)
Has anyone successfully implemented continuous BLE monitoring in background/sleep modes? Are there any special entitlements or techniques that could help achieve this?
This is for a safety-critical application where missing sensor data could lead to serious issues.
Any guidance would be greatly appreciated.
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
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)
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.
Topic:
App & System Services
SubTopic:
Maps & Location
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.
Topic:
App & System Services
SubTopic:
Maps & Location
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.
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
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?
My app needs to track background location for a period of several hours while the user is using it, and we want to allow the user to switch apps or lock their phone while this is happening. We don't need to track location permanently and because of this, we don't want to request the "Always allow" permission.
The app requests "While in use" permission and it has the "Location updates" background mode enabled. The CLLocationManager has 'allowsBackgroundLocationUpdates' set to true, 'pausesLocationUpdatesAutomatically' false, kCLLocationAccuracyBest, kCLDistanceFilterNone, and .fitness for the activity type (we expect the user to be walking).
The app also initializes a CLBackgroundActivitySession while it is tracking location and invalidates it when done.
When I test this combination on my iPhone, it works fine. I get location tracking in the background for as long as I need it, regardless of what else I do with the phone.
However, my customer says it doesn't work for him. He is using a Wifi-only iPad with an external GPS receiver called "BadElf GPS Pro". He says that the external GPS receiver works fine with other apps on his iPad. With my app, he gets background location tracking only for a short time, and then it stops.
The app does monitor the "locationManagerDidPauseLocationUpdates" callback and posts a local notification if it gets called, but it doesn't get called. I've also confirmed with him that he is not force-quitting the app and the app is not otherwise being terminated by iOS.
Is there something I'm missing?
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!
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Core Location
Maps and Location
Background Tasks
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.