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

Issue with geolocation without using maps
I have an application that uses geolocation to track the user’s location and trigger actions when the app is in either the foreground or background. Currently, it seems that region entry is not triggered unless an app like Maps (which actively uses location services) is opened. The location permissions are correctly set to “Always” with precise location enabled. We are using geofencing to setup region and trigger actions when entering or leaving. Is there something I’m missing in the configuration that could be preventing region monitoring from triggering properly when the app is in use or in background?
4
0
512
Nov ’24
CLMonitor init function causes app crash
I'm experiencing app crashes when calling the CLMonitor initialization function: let monitor = await CLMonitor("my_monitor") According to WWDC 2023: Meet Core Location Monitor, when creating a CLMonitor object with the same identifier, it should access the existing monitor without any mention of app crashes or buggy behavior. However, in my actual testing, attempting to create a CLMonitor object with the same identifier immediately causes an app crash. Here's part of the crash log: Last Exception Backtrace: 0 CoreFoundation 0x19c4ab21c __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x199945abc objc_exception_throw + 88 (objc-exception.mm:356) 2 Foundation 0x19b7a9670 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 288 (NSException.m:252) 3 CoreLocation 0x1aa25cbb4 +[CLMonitor _requestMonitorWithConfiguration:locationManager:completion:] + 516 (CLMonitor.mm:516) 4 libswiftCoreLocation.dylib 0x22bf6085c CLMonitor.init(_:) + 488 (CLMonitor.swift:280) 5 libswiftCoreLocation.dylib 0x22bf604b9 <deduplicated_symbol> + 1 6 MiniPlengi 0x106372ec9 closure #1 in static CLMonitor.loplatMonitor.getter + 1 (CLMonitor+Extensions.swift:31) 7 MiniPlengi 0x1062ce325 0x106290000 + 254757 8 MiniPlengi 0x1062f6a29 specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1 (/<compiler-generated>:0) 9 MiniPlengi 0x1062ce325 0x106290000 + 254757 10 libswift_Concurrency.dylib 0x1a7f75241 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:537) Furthermore, even though I've written code to create CLMonitor objects based on a singleton structure to handle these crash cases, the app still crashes: extension CLMonitor { static var loplatMonitor: CLMonitor { get async { struct Static { static var monitor: CLMonitor? static var initializationTask: Task<CLMonitor, Never>? } // If already initialized if let monitor = Static.monitor { return monitor } // If there's an initialization task in progress, wait for its result if let task = Static.initializationTask { return await task.value } // Create new initialization task let task = Task { let monitor = await CLMonitor("my_monitor") Static.monitor = monitor Static.initializationTask = nil // Clean up task after completion return monitor } Static.initializationTask = task return await task.value } } } Is the CLMonitor API still in a stabilization phase and not recommended for production release? I would appreciate guidance on the correct usage. If these issues are expected to persist, I'm wondering if I should continue using the existing CLCircularRegion API instead. Any insights or recommendations would be greatly appreciated.
1
0
39
6d
Location Verification API's
Dear Apple Team, I am reaching out regarding the need for more sophisticated location verification APIs beyond basic IP lookup capabilities. As online fraud continues to evolve, IP-based geolocation has proven insufficient for many business use cases requiring accurate location verification. Would it be possible to discuss this proposal with your API development team? I believe this would be valuable for the entire iOS and macOS developer ecosystem while maintaining Apple's commitment to user privacy.
0
0
89
Jun ’25
CMAltimeter becomes somehow uncalibrated: absolute locations not delivered anymore (temporarily)
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!
0
0
284
Feb ’25
How the duck can I use .p8 to get the Mapkit Server API token to use it without 7 day duration?
https://developer.apple.com/documentation/applemapsserverapi/creating-and-using-tokens-with-maps-server-api This doesn't really say what to do with .p8 private key. I know I am a noob but I really don't understand Apple Doc at all. There is no example or anything like that. const appleMapKit = await fetch("https://maps-api.apple.com/v1/token", { headers: { Authorization: `Bearer ${server_api_token}`, }, }); This is what I did but because I created the token on website, server_api_token only lasts 7 days. So, I tried to use Profile - Key to replace that. I have .p8 file and how can I use this to create the token for the server api?
1
0
588
Nov ’24
The App Remembers Location Access Permission only for 24 Hours
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,
0
0
311
Mar ’25
Working with visits and significant location changes following Core Location updates in iOS 17 and iOS 18
Hello, I'm working on an application that requires the use of significant location changes and visits, in addition to region monitoring and standard continuous location delivery (foreground and background). iOS 17 and iOS 18 introduced changes to how we can monitor distinct regions of interest (with CLMonitor) as well as receive location updates (with CLLocationUpdate). But I couldn't find any information regarding how to work with Significant location changes. Do we still need to create a location manager and call startMonitoringSignificantLocationChanges()? Where are the updates received in this case, in the locationManager(_:didUpdateLocations:) or in the liveUpdates async sequence? Visits. Same question here, for visit monitoring to work, do we still have to create a location manager then call startMonitoringVisits()? Where are the visits being notified? Still in locationManager(_:didVisit:) or in the liveUpdates asynchronous sequence? I just want to be sure I understand correctly how to use the updates, and if some features of Core Location still need to use a location manager and the delegate to receive the events. Maybe additional CLCondition will be added to cover both of these technologies as it seems highly related to monitoring conditions (significant location change, and visit). Thank you, Axel
0
0
101
Jul ’25
What are the criteria for CLVisit in CoreLocation?
There is no official documentation specifying the exact criteria for determining a CLVisit. For example, if a user starts at a target location, will the following method be called? func locationManager(_ manager: CLLocationManager, didVisit visit: CLVisit) This did not work during my testing. It was only successfully triggered when starting from a distant location and arriving at the target point. It would be helpful to know the exact conditions, such as how long a user must stay at a location for it to be considered a visit. Are there any specific thresholds (e.g., minimum duration, distance moved) that determine when this method is triggered?
0
0
183
Mar ’25
MapkitJS Snapshot
I am having issues loading in a mapkit snapshot. I get an error saying that https://domain.com and they're expecting domain.com. I have no idea what could be going wrong here. I set the domains properly in the mapkit tokens. When I click on the link it opens a new tab and loads what the data properly, but somehow in the application on production this error comes up.
0
0
328
Jan ’25
Unreliable CLServiceSession(authorization: .always) when using other background modes.
I am using CLServiceSession(authorization: .always) to start a service session for tracking Zone entry and exit in the background in my app. It has been working fine on iOS 18 until recently when we added some BGProcessingTasks. The task runs when the user is not moving and the device is on charge, this task runs fro a bit in the background, however we are seeing that even though we are reinitializing then session upon app launch. We have even tried to just explicitly reinitialize a session within the background task callback, but the zone tracking still continues to fail. Significant location changes are unaffected. Timeline of events: User Opens App, CLServiceSession(authorization: .always) is called (assume permissions have already been granted.) App is backgrounded User moves outside zone and app captures the data correctly (this can happen any amount of times) User plugs in Phone BGProcessingTask callback is run, it may or may not be terminated early. The service session is recreated as the first action in the callback. (we have also tried putting it in the main init() function for the app, same outcome) User moves outside zone later and app does NOT capture the data. User is sad :( The session seems to be reinitialized correctly when the app is launched due to CoreLocation updates. Is this expected behaviour or a bug? Is there a good way to debug what is happening with the sessions? Unfortunately, the WWDC sessions on this have not enlightened us about the cause of this behaviour.
0
0
360
Dec ’24
Location and Photo permission String purpose
I have App uploaded to app store but it was rejected 5 times because of the location and photo permission purpose string the idea of the app is to add compliment , choose the location on the map and some info and the location is not associated to user identity it just to show his place on the map if the place he want to pick is near him he can refuse location permission the map can open and pick the point he want and need permission for images to add images with compliment , I need help for location and images permission purpose string.
2
0
337
Dec ’24
Specify location for SwiftUI Previews
I'm working on an app that uses MapKit and CoreLocation. Is there a way to specify what location is simulated for a Preview, or create a preview that behaves as if the user denied location permissions, so that I can easily test my app's behavior in different scenarios? I know that you can simulate different locations in the Simulator, but haven't been able to get the previews within Xcode to have a location other than the center of Apple Park.
0
0
69
Apr ’25
didEnterRegion and didExitRegion delegate methods are called twice
When I set the values of notifyOnExit and notifyOnEnter to true when registering CLCircularRegion, I checked that the didExitRegion and didEnterRegion functions are called well. However, there is a problem that they are called twice in a row every time they are called. I was wondering if this is an internal bug in the API. There is also a stackoverflow report related to the above issue. I would appreciate your confirmation. stackoverflow - why the didEnterRegion called twice? Thank you.
1
0
509
Dec ’24
Weather App
I keep getting severe weather warnings in CA but I’m in NY. I have checked my locations and I have no CA weather requests selected. I clicked on the alert and it said it was from weatherkit. How do I make these CA go away for good? Thanks!
3
0
496
Oct ’24
[CoreLocation][iOS 18.3.2] OS is not notifying monitored region state to application
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
1
0
126
Apr ’25