I might be being really ******, but I'm struggling to find a way to update the map kit token when it expires. We have a display that shows a map for a long time and for some reason the map stops loading and I think it's cause the token expires however I can't work out away to tell it to load a new token.
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
I have a CarPlay navigation app and I would like to allow the user to speak an address and have our app search at that location.
In the Waze app, it provides a button to tap, then it brings up a CPVoiceControlTemplate and you can give it directions or a location and it will then show you search results including the text you spoke as the title. I assume that app would have the same limitations as I do, so I am wondering how another app might do this?
It was suggested that I use an App Intent with suggested phrases and then a Shortcut could perform the action. Is there documentation on this somewhere or am I going in the wrong direction here?
Obviously Waze is doing what I am wanting so there must be a way. Can anyone point me in the right direction?
I am looking into a piece of old code where the mentioned method is called.
+ (bool)isLocationServicesEnabled {
return [CLLocationManager locationServicesEnabled];
}
I'm getting the classic "This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first."
I have 2 questions:
What is that error about, really? The locationServicesEnabled() has nothing to do with authorisation, it's just about the "location services" settings global on-off switch? (the authorisation check is .authorizationStatus)
I don't understand why that call is such a big issue? It's just a setting? Why would that be so costly?
Thankful for pointers! Have a good one
We met a question recently in our project, we try to achieve the SSID,so we need to do the following two things :
request location permission
add the capability of "Access Wi-Fi information"
then the app always shows the location access indicator.
, In the app privacy report , we see the app always request the location.
But when I try to remove "Access Wi-Fi information" the capability , the scenario disappear.
Any ideas can explain this ? How can I remove the location access indicator with out remove the "Access Wi-Fi information" . I indeed need this.
Thanks in advance.
Is it possible to fetch the user's latitude and longitude after the app has been manually terminated? If so, could you please provide a solution?
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)
}
}
I own a website (timeguessr.com) that uses the apple mapkit js api. I have had a number of reports in the last few weeks of users having the map not loading.
Since I have not been able to recreate the problem I have asked people to send screenshots of what is logged to their developer tools console. In each case a ERR_HTTP2_PROTOCOL_ERROR 200 (OK) error is being logged when the user is trying to fetch from cdn.apple-mapkit.com endpoints.
What is strange is this happens halfway through their games when they have already successfully loaded the map in previous rounds.
Can anyone help? Thanks
I've noticed in the past few weeks that the minutely precipitation values reported by WeatherKit are much bigger than they were before. Specifically I'm referring to WeatherKit.MinuteWeather.precipitationIntensity.
In my app, I convert to mm per hour:
let mmPerHour = $0.precipitationIntensity.converted(to: UnitSpeed.kilometersPerHour).value * 1e6
This has worked perfectly since WeatherKit came out, but now when I look at rainy locations and compare with the built-in Apple Weather app on my phone, it seems that the new values are about 3x what they should be. I have checked this in multiple locations across the USA.
My intuition says this is an inches/cm conversion issue (2.54x). Is this an intentional change in WeatherKit that requires me to update my app, or is this a bug on Apple's end??
How to change the Type of Map to be Public Transport? I want to see a public transport map.
Thanks
I always get the user location not found error even though I have activated my location
import SwiftUI
import MapKit
import CoreLocation
class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
private let locationManager = CLLocationManager()
@Published var location: CLLocation? = nil
@Published var authorizationStatus: CLAuthorizationStatus? = nil
override init() {
super.init()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let newLocation = locations.last else { return }
location = newLocation
print("Updated location: \(newLocation.coordinate.latitude), \(newLocation.coordinate.longitude)")
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
authorizationStatus = status
if status == .authorizedWhenInUse || status == .authorizedAlways {
locationManager.startUpdatingLocation()
}
}
}
private func sectionTitle(_ title: String) -> some View {
Text(title)
.font(.headline)
.fontWeight(.bold)
.padding(.bottom, 8)
}
private func openAppleMaps() {
let destinationLatitude: CLLocationDegrees = -6.914744
let destinationLongitude: CLLocationDegrees = 107.609810
guard let currentLocation = locationManager.location?.coordinate else {
print("Lokasi pengguna tidak ditemukan.")
return
}
let currentLatitude = currentLocation.latitude
let currentLongitude = currentLocation.longitude
// URL encode parameters
let urlString = "http://maps.apple.com/?saddr=\(currentLatitude),\(currentLongitude)&daddr=\(destinationLatitude),\(destinationLongitude)&dirflg=d"
guard let appleMapsUrl = URL(string: urlString) else {
print("URL tidak valid.")
return
}
// Open Apple Maps
UIApplication.shared.open(appleMapsUrl, options: [:]) { success in
if !success {
print("Gagal membuka Apple Maps.")
}
}
}
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
App Store
Xcode Server
Xcode
Developer Tools
Good day! I have an app that collects location data in the background, and I'm wondering if there's a way to disable the location warning.
Hi,
Please let me know iOS 18 beta have deprecated/ stopped support for which of the following:
proximityUUID
CLBeaconRegion
(instancetype)initWithProximityUUID:(NSUUID *)proximityUUID identifier:(NSString *)identifier
(void)startRangingBeaconsInRegion:(CLBeaconRegion *)region
-startRangingBeaconsSatisfyingConstraint: , is this also deprecated in iOS 18 beta, since: CLBeaconIdentityConstraint is deprecated right?
CLBeaconIdentityCondition is not supported in XCode 15.3. What should I do for this? Should I install XCode 16 beta?
locationManager:didRangeBeacons:satisfyingConstraint: can we use it in iOS 18 beta, since, CLBeaconIdentityConstraint is deprecated? what is alternative
startMonitoring(for:) is also deprecated in iOS 18 beta right?
Also, can someone specify or create a documentation on how beaconing shall be monitored, ranged and locationManager delegate methods pertaining to beaconing to be used in iOS 18 beta?
My query might return 20,000 coordinates.
Does MapKit JS try to load all the coordinates at once into the map or does it only load what’s in the viewport of the map if we were to load 20,000 annotations into the say something like “landmark data” const?
We have 900,000 coordinates to load into Los Angeles and are planning how we will do this. Obviously we can’t load 900,000 coordinates at once without performance issues, but some query’s return 20,000 results.
Can someone point me to some information about large datasets and MapKit js or let me know if it’s handled and already built in to not try to load that many locations at once?
I wish to add location icon on/off in control center, like wifi icon or bluetooth icon it will be more easier and save the battery
Topic:
App & System Services
SubTopic:
Maps & Location
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
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Extensions
Core Location
Maps and Location
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?
I have a UIKit app with an MKMapview.
In that mapview, I show icons on the location of Airfields.
When zooming out to Europe (or USA for that matter), the whole map is covered with the annotations, so I want to only show these annotations when zoomed in beyond some level.
How can that be achieved?
I did find a way like this:
class MapViewController: UIViewController {
var isAtBigZoom = true {
didSet {
guard oldValue != isAtBigZoom else {
return
}
for case let annot in mapView.annotations {
mapView.view(for: annot)?.alpha = isAtBigZoom ? 1 : 0
}
}
}
}
extension MapViewController: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, regionWillChangeAnimated animated: Bool) {
isAtBigZoom = mapView.region.span.latitudeDelta < self.airportThreshold
}
}
But I have 2 problems with that:
Seems like a lot of processing power
It only takes effect after a pan. So I zoom beyond the limit, alpha has the 'old' value. Only after I pan, the alpha is suddenly represented in the MapView.
Does anybody know a better solution?
Hello,
It’s unclear to me if there is a limit of requests when using MKLocalSearch from MapKit.
Let’s say I have a very large user base and will use 1000 requests per minute at peak times. Will MapKit support this?
But if there is a limit, is it by user or by developer account? Also, if there is a limit, is it per day?
Here is an example of the request we use.
let searchRequest = MKLocalSearch.Request()
searchRequest.naturalLanguageQuery = myQueryStringHere
localSearch?.cancel() // cancel the previous call if it exists
localSearch = MKLocalSearch(request: searchRequest)
localSearch?.start { (response, error) in
guard error == nil else {
completion(.failure(.myError))
return
}
let mapSearchLocations = response?.mapItems
completion(.success(mapSearchLocations))
}
}
Hi! I was wondering what the expected behavior of CLServiceSession(authorization: .always) after a device restart was?
What I am observing right now is that, after a device restart, location access from the background is denied until the app enters the foreground for the first time (CLServiceSession.Diagnostic says insufficientlyInUse: true; CLLocationUpdate additionally says serviceSessionRequired: true).
Is this the expected behavior?
If it is, then this seems like a somewhat suboptimal user experience to me, at least for my use case - the user's intention regarding the background location access won't have changed just because the device was rebooted.
(In case this is relevant, my use case is transmitting the current location to connected Bluetooth devices, e.g. digital cameras. As such my app is setting UIBackgroundModes of ["bluetooth-central”]).
There is no more way to change location name in Find My, or change what device the Find My location should be on in iOS18.