Build maps and location awareness capabilities into your apps.

All subtopics

Post

Replies

Boosts

Views

Activity

CarPlay Map Displays White Screen
Hello, I'm somewhat new to CarPlay integration and am having an issue. I have ready through Apple's CarPlay Programming Guide, reviewed their code samples and have exhausted my searches online to help find a solution to my problem. I have been unable to get a basic map to display on my CarPlay map utilizing the following: import CarPlay class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate { var interfaceController: CPInterfaceController? var window: CPWindow? func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController) { self.interfaceController = interfaceController let mapTemplate = CPMapTemplate() mapTemplate.mapDelegate = self interfaceController.setRootTemplate(mapTemplate, animated: true, completion: { success, error in if let error = error { debugPrint("Error: \(error)") } else { print("CarPlay Map Should Be Displayed") } }) let trip = CPTrip(origin: MKMapItem(placemark: .init(coordinate: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0))), destination: MKMapItem(placemark: .init(coordinate: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0))), routeChoices: []) mapTemplate.startNavigationSession(for: trip) } } extension CarPlaySceneDelegate: CPMapTemplateDelegate { func mapTemplate(_ mapTemplate: CPMapTemplate, panWith direction: CPMapTemplate.PanDirection) { // Handle panning } func mapTemplate(_ mapTemplate: CPMapTemplate, startedTrip trip: CPTrip, using routeChoice: CPRouteChoice) { // Handle trip start } } I have my CarPlay Entitlements setup, I have my CarPlay Navigation App set in my signing and capabilities and my app icon displays properly on CarPlay (both in simulator and inside of my vehicle). However, as mentioned I only get a white screen. Now, if I utilize the following code, I will get my map to display, however I lose functionality such as panning the map. I'm sure that I am missing something simple on the above example and appreciate any guidance that you may have. func createMapTemplate(destination: TripDetails?, destinationBL: BucketListItems?, route: MKRoute, window: UIWindow) -> CPMapTemplate { mapTemplate = CPMapTemplate() mapTemplate.mapDelegate = self trip = nil let startLocation = CLLocation(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude) let startMapItem = MKMapItem(placemark: MKPlacemark(coordinate: startLocation.coordinate)) startMapItem.name = "Starting Location" let endMapItem = MKMapItem(placemark: MKPlacemark(coordinate: route.polyline.points()[route.polyline.pointCount - 1].coordinate)) endMapItem.name = destination?.campgroundName != nil ? destination!.campgroundName : destinationBL!.name // Create the hosting controller for the SwiftUI view let mapViewController = UIHostingController(rootView: CarPlayMapView(templateManager: self)) window.rootViewController = mapViewController window.makeKeyAndVisible() let routeChoice = createCPRouteChoice(from: route) trip = CPTrip(origin: startMapItem, destination: endMapItem, routeChoices: [routeChoice]) mapTemplate(mapTemplate, selectedPreviewFor: trip!, using: routeChoice) mapTemplate.showTripPreviews([trip!], textConfiguration: nil) return mapTemplate }
1
0
379
Aug ’24
How can I ensure that the GNSS received on iOS is reliable at the decimeter to centimeter level?
I am trying to use GNSS data to track the location of a mobile phone with high precision. I understand that using Fused Location provided by iOS can improve accuracy, but it is not perfect. To inform the user when the current GNSS location is somewhat inaccurate (with meter-level error), which data fields should I rely on? (e.g., horizontal accuracy, vertical accuracy) Additionally, I am curious if iOS currently supports dual-band GNSS calculations (e.g., SBAS, BeiDou-3, etc.). If supported, which API can be used to determine this status?
1
0
400
Aug ’24
Push Location Service Entitlement
Hello! Back on April 4th our team requested the push location service entitlement. Our app requires very similar background tracking as Find my or Life 360 where users agree to share locations and another user might want to prompt for an update. Since submitting on April 4th, we have received no response or update from our request. I've called and emailed with developer support 20+ separate times (They've escalated it at least 10 times at this point) with no response either. I've also submitted new requests in case our original got lost. Is there anyone else we can contact or talk with to get any progress? The developer support team is even at a loss for how long this is taking now. We are just completely lost on what our next step could be
1
1
327
Aug ’24
SwiftUI and MapKit - Find address from coordinates
I've seen a lot of posts around the internet about getting coordinates from an address, but none about how to do the opposite. What I would like to do is allow a person to drop a pin and then programmatically look up the address closest to the pin. Like if I drop a pin inside a mall on the map I would like to capture the address to the mall. Does anyone know how this could be done?
2
0
371
Aug ’24
How can I get something similar to launchOptions[UIApplication.LaunchOptionsKey.location] in SceneDelegate for iOS 13+ apps
I'm making an app for iOS 13+ devices. My project has both app delegate and scene delegate files. I'm using core location for significant location changes. I was able to detect significant location changes and system waking up my app in simulator using SignificantlyChanged app’s scheme. But when the launch options dictionary has 0 elements and the value for the key UIApplication.LaunchOptionsKey.location is always nil. Here is my AppDelegate.swift where the system will launch the app in background state when a significant location change is detected and execute the location fetch code. And location manager class. I want to know if the app is launched my the system or if it is launched by the user so I want to check if UIApplication.LaunchOptionsKey.location key has a value. But it is always nil and there is no alternative to it in SceneDelegate. When and how can I find a solution to this long due issue. import CoreLocation @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. if launchOptions != nil{ if launchOptions![UIApplication.LaunchOptionsKey.location] != nil{ print("Called from background location fetch") } } LocationService.shared.askForPermission() LocationService.shared.delegate = self return true } // MARK: UISceneSession Lifecycle func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with. return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { // Called when the user discards a scene session. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. // Use this method to release any resources that were specific to the discarded scenes, as they will not return. } } extension AppDelegate: LocationMangerDelegate{ func didFetchLocation(coordinate: CLLocationCoordinate2D) { print(coordinate) } func didFailToFetchLocation(error: Error?, message: String) { print(message) } }``` import Foundation import CoreLocation protocol LocationMangerDelegate: AnyObject{ func didFetchLocation(coordinate: CLLocationCoordinate2D) func didFailToFetchLocation(error: Error?,message: String) } class LocationService: NSObject{ private override init() { } weak var delegate: LocationMangerDelegate? static var shared = LocationService() lazy var locationManager: CLLocationManager = { var manager = CLLocationManager() manager.desiredAccuracy = kCLLocationAccuracyBest manager.allowsBackgroundLocationUpdates = true manager.pausesLocationUpdatesAutomatically = false manager.delegate = self return manager }() func askForPermission(){ print("INSIDE") locationManager.requestWhenInUseAuthorization() } func startLocationUpdates(){ self.locationManager.startUpdatingLocation() } func stopLocationUpdates(){ self.locationManager.stopUpdatingLocation() } } extension LocationService: CLLocationManagerDelegate{ func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { let status = manager.authorizationStatus switch status { case .notDetermined: self.askForPermission() case .restricted: self.delegate?.didFailToFetchLocation(error: nil, message: "Location permission is restricted by the user") case .denied: self.delegate?.didFailToFetchLocation(error: nil, message: "Location permission is denied by the user") case .authorizedWhenInUse: self.locationManager.requestAlwaysAuthorization() case .authorizedAlways: self.locationManager.startMonitoringSignificantLocationChanges() @unknown default: break } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { if let location = locations.first{ print(location) self.delegate?.didFetchLocation(coordinate: location.coordinate) self.stopLocationUpdates() } } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print(error) self.delegate?.didFailToFetchLocation(error: error, message: error.localizedDescription) } }
1
0
383
Aug ’24
App Clips Advanced Experiences not showing up in Apple Maps and Siri Suggestions
Hello everyone, I’m experiencing an issue with App Clips Advanced Experiences and Apple Maps/Siri Suggestions. We have already contacted Apple Support before, but they are investigating the cause of this issue and it has not been resolved til date. The App Clip is bundled with the main app and has been already available on the App Store for several months. The business running the app has several physical shops and wants to offer the App Clip to show up in Apple Maps and Siri Suggestions at each location. The App Clip is correctly exposed in the AASA file, and it's also validated correctly by the AASA APIs available at https://app-site-association.cdn-apple.com/a/v1. { "applinks": { "apps": [], "details": [ { "appID": "TEAMID.bundleid", "paths": [] } ] }, "appclips": { "apps": [ "TEAMID.bundleid.Clip" ] } } (with TEAMID and bundleid being the team and bundle identifiers of the app) The App Clip is displayed correctly when loading the website and when scanning a QR code or App Clip code, but doesn't appear in the Maps app or in Siri suggestions. We have set up the App Clip Advanced Experiences on the App Store Connect page of the app, and each URL has been linked to a physical shop. All URLs are in the "Received" state, so they should appear correctly on Maps. Unfortunately, I don't see any "Order" button in Apple Maps at any location card. We tried with both iOS 17 and 16. According to feedbacks from people in the shops, they don't see the app suggested in the Siri Suggestions. I have just submitted a Custom Action Link on Apple Business Connect for one of the shops, but without success: the App Clip doesn't appear. Any idea why is this happening?
6
1
507
Sep ’24
Not getting User's location in Background Mode
We developed a app in which the I need the app to update the User's location even in background( even after terminating from the recent UI ), Currently I am receiving the location updates when the user has kept the app in open and if minimised, But I want that it should update the location even when it is removed from recent app (minimised UI)(after terminating the app) Is it possible to do so.???
3
0
491
Sep ’24
Prevent pausing location updates on background when stationary?
Hello, I'm trying to receive location updates on background mode but it only lasts about 10 minutes then it stops when API detected the "isStationary" is true. Is there any way to continue receiving updates even when the device is stationary? Btw app is not terminated by the user. I'm using CLLocationUpdate.liveUpdates(.otherNavigation) API. CLBackgroundActivitySession is created before calling the liveUpdates. CLLocationManager: let manager: CLLocationManager = { let manager = CLLocationManager() manager.distanceFilter = kCLDistanceFilterNone manager.desiredAccuracy = kCLLocationAccuracyThreeKilometers manager.pausesLocationUpdatesAutomatically = false manager.activityType = .other manager.showsBackgroundLocationIndicator = true manager.allowsBackgroundLocationUpdates = true return manager }() Thank you!
3
0
420
Sep ’24
MKLocalSearch for cities not returning location identities
Hi fellow developers, I'm encountering an issue when using MKLocalSearch to search for cities. Here's my setup: I'm using MKLocalSearch with an MKLocalSearch.Request object. I've set the resultTypes to .address to focus on address results. The problem: When I receive the search response, it includes the locations as expected. However, these locations don't have an identity or alternative identities. Questions: Is this the expected behavior when searching for cities? Without an identity, how can I uniquely identify and store these city results in my database? Would it be appropriate to store the city name, country, and coordinates instead? Thanks in advance!
0
0
218
Sep ’24
MKLocalSearch for cities - How to uniquely identify results?
I'm using MKLocalSearch with resultTypes set to .address to search for cities. The search results don't include an ID for each city, which I need for database storage (which from my understanding is the only thing we can store). If I can't store the city name, country, and coordinates in my database, and I'm not allowed to use third-party data (like a pre-made list of cities with coordinates), what are my options for uniquely identifying and storing these city results? Any suggestions would be greatly appreciated.
0
0
187
Oct ’24
GPS Icon Appears on App Launch Despite No CLLocationManager Usage – Need Help Tracing Cause
Hello everyone, I’m facing an issue with my iOS app where the GPS/location services icon appears in the status bar immediately when the app is launched, even though I’m not intentionally accessing location services at that point. Issue Summary: • GPS Icon Activation: When I launch my app, the GPS icon turns on. It turns off when the app is minimized or closed. • No Intentional Location Usage at Launch: I have ensured that no instances of CLLocationManager are created when the app is launched. What I’ve Tried So Far: 1. Checked Controllers and Related Classes: • Reviewed all the code for the controllers that are active at launch. • Verified that none of these controllers create instances of CLLocationManager or call location-related methods. 2. Commented Out startUpdatingLocation: • Commented out all calls to startUpdatingLocation throughout the entire project. 3. Ensured No CLLocationManager Instances at Launch: • Searched for any code that might instantiate CLLocationManager during app launch. • Confirmed that no such instances are being created. 4. Commented Out Google Maps SDK Configuration: • In AppDelegate, commented out the Google Maps SDK configuration, so it’s not initialized with the API key. • No map views (GMSMapView, MKMapView) are initialized or used when the app is launched. 5. Tested Location Permissions: • When I change the location permission for the app to “Never” in the Settings app, the GPS icon does not appear upon app launch. • This suggests that the app is accessing location services when it has permission, even though I haven’t explicitly requested it at launch. Objective: • Control GPS Activation: I want to ensure that the GPS does not turn on when the app is launched. I intend to activate location services only when needed later in the app. Request for Assistance: I’m seeking guidance on the following: 1. Debugging Techniques: • How can I trace the code that’s causing the GPS to turn on at app launch? • Are there tools or methods to identify hidden or indirect calls to location services? 2. Forcing Location Services Off at Launch: • Is there a way to programmatically prevent location services from activating during app launch? • Can I defer any implicit location service initialization until I explicitly enable it? 3. Potential Hidden Triggers: • Are there known scenarios where location services could be activated without direct use of CLLocationManager? • Could frameworks like Google Maps SDK trigger location services even if not fully initialized? 4. Additional Suggestions: • Any other insights or suggestions to prevent the GPS icon from appearing on app launch. Additional Information: • Third-Party Frameworks: • I have not removed third-party frameworks yet, as I wanted to check other possibilities first. • Open to the idea that a third-party framework might be causing this, but need guidance on how to confirm. • Code Availability: • I’m happy to provide specific code snippets if that would help diagnose the issue. Environment: • Xcode Version: Xcode 15.4, Xcode 16.0 • iOS Deployment Target: iOS 15.0 • Devices Tested: iPhone SE 2nd and 3rd gen, iPhone 15, iPhone 15 pro, iPhone 11 • Programming Language: Swift What I’m Looking For: • Assistance in tracing the cause of the GPS activation on app launch. • Suggestions on how to prevent location services from starting until explicitly needed. • Insights into any hidden triggers or indirect usages that might cause this behavior. Thank you for your time and assistance. Any help to resolve this issue would be greatly appreciated.
1
1
214
Oct ’24
Apple Maps Not responding to scrolling, zooming, or tap gestures on custom pins
Scrolling and zooming I have two apps that utilize the Apple Maps and since I updated my xcode to use IOS18, some of the functionalities have either been missing or glitching, and when I roll back to IOS17.5, everything seems to work fine. When I use MKMapView and use mapView.isZoomEnabled = true mapView.isScrollEnabled = true Scrolling and zooming is still not working on IOS18 but IOS17.5 works fine. Clicking on custom annotations When I press on a custom annotation I add to the MapView, the gesture is sometimes recognized and most of the times not recognized. If I have 20 annotations, there is a possibility only 2 of them respond to tap gestures. Below is how I define the annotation. Annotation("Pin", coordinate: CLLocationCoordinate2D(latitude: latitude, longitude: longitude), anchor: .bottom) { Button(action: {print ("Pressed annotation"){ CustomPin() } }
0
0
164
Oct ’24
Core Location always failing (kCLErrorLocationUnknown)
Hello. I’m trying to use Core Location Service on any application in Mac (Safari, Maps, Weather, Chrome with Core Location configuration, or just trigger the API with a standalone app) and it seems that all of them constantly fail to provide the geolocation of my device because of the same error (kCLErrorLocationUnknown). I'm using MacBook Pro (M3 Max) with Sonoma 14.7. I’m sure the apps have access in the settings and everything is in order except the Core Location response. I’ve tested the issue on multiple MacBooks and it reproduced 100% of the times on all of them. Did anyone encounter a similar issue?
0
0
266
Oct ’24
GPS Coordinates with Photos
I am currently developing an application that requires access to GPS coordinates from photos on iOS. However, with the recent update to iOS 18 beta, I have encountered a challenge: I can only view photos within maps, and I am unable to access the GPS coordinates directly. Could you please provide guidance on how to enable or retrieve GPS coordinates from photos in the current iOS 18 beta version? Any insights or resources you could share would be greatly appreciated. Thank you for your assistance!
1
0
175
Oct ’24
How do simulate custom moving location
For some background, my app is a Flutter app and I have opened it in xcode to try the following, I can build and run it on a simulator from xcode as well. I want to be able to simulate custom moving locations for my app. I tried going to Debug -> Simulate Location like online tutorials show but it is all greyed out. I have location simulation enabled (I have tried changing the default location too): Within the simulator itself I only have the predefined routes or a custom static location with no option for a moving location. How can I simulate a custom moving location? If it isn't possible is there anyway to simulate the location for a Mac app as I can build the Flutter app for Mac as well?
3
0
231
Oct ’24
Intermittent MKLocalSearch.Request Failures with Amap Data Source
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
1
0
164
Oct ’24
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
194
4w