Core Location

RSS for tag

Obtain the geographic location and orientation of a device using Core Location.

Core Location Documentation

Posts under Core Location tag

162 Posts
Sort by:
Post not yet marked as solved
2 Replies
802 Views
I'm following Apple guidelines to add the Location Push Service Extension to our app. I followed these steps: I applied and got approved for Location Push Service Extension. My app already asks the user for "Always" permissions for location updates I added the entitlement key com.apple.developer.location.push = TRUE I added to the project a new Target, and selected Location Push Service Extension from the iOS Application Extension group I encouter the following issue. When I run the app and call startMonitoringLocationPushes(completion:) I receive the following error: Error Domain=CLLocationPushServiceErrorDomain Code=1 "(null)" By looking at Apple documentation for CLLocationPushServiceErrorDomain, code 1 stands for: missingPushExtension An error code that indicates the app is missing a Location Push Service Extension. As mentioned beofore I already added the Location Service Extension Target to the project. Any idea of why I receive this error? Thanks
Posted
by
Post not yet marked as solved
0 Replies
591 Views
Hello there! I open a URL with SFSafariViewController inside my app. The URL that opens should ask for permission for the location information as the first step. It works seamlessly through the normal safari application. But when it is opened with SafariServices in the app, I cannot get the location information. When I press the aA icon in the upper right corner of SafariServices UI and open the website settings, although the location part is selected as "Ask", it does not ask for permission for location information and does not see the location.
Posted
by
Post not yet marked as solved
5 Replies
1.6k Views
Below resources says that I cannot. I don't see satellite count related API in Core Location framework document also. 1)This is not possible using any publicly available iOS API. (2012/11/8) https://stackoverflow.com/a/13309242/809671 2)There is no public available API that allows you to get this kind of detailed information about the GPS satellites. (2010/8/24) https://stackoverflow.com/questions/3555732/is-there-a-way-to-get-detailled-gps-satellites-info-on-iphone 3)Confirmed that your app does not have access to the private API used to suss that information. (2017) https://developer.apple.com/forums/thread/73220 4)Since ios does not provide the number of satellites, and since phone gap is designed as a subset of functionality that runs on all phoneplattform, the num satellites is not available. (2015/11/4) https://stackoverflow.com/questions/33516688/phonegap-cordova-get-number-of-gps-satellites 5)The Public SDK doesn't expose that. (2009/12/17) https://stackoverflow.com/questions/1919553/is-it-possible-to-get-gps-satellite-numbers-via-iphone-sdk 6)Can iOS 8 provide info on satellites? No. (2014/8/20) https://forums.macrumors.com/threads/can-ios-8-provide-info-on-satellites.1766861/ Above posts are little old so I want to double confirm. If an Apple developer can reply this then it would be better thanks.
Posted
by
Post not yet marked as solved
1 Replies
631 Views
A new feature in Settings > privacy & Security> Location Services that allows users to disable location access for all installed 3rd party applications. I think this is a great idea. It would save battery life and improve privacy for users. It would also be helpful for tracking kids and teenagers, as well as for people with Alzheimer's or dementia and syndrome down people. Apple and Google should store children and teenagers' school locations on their Apple or Google accounts. I think this is a good idea, but I don't think it should be mandatory. Parents should have the option of whether or not to share their child's school location. this helps to protect our teenagers to be safe. Apple should distinguish between known locations, such as home, work, and school. This would be a helpful feature for apps that need to know where the user is located. For example, a delivery app or Amazon iOS App could use this information to let the user know when their package is expected to arrive. Apple should create a Location Known Kit for Location access. This would allow apps to share location information with each other. and there is no need to check over and over by different 3rd party who installed multiple and different applications to check the Locations over and over and it's a disaster that if users are at home or at workplace or at school most majority of the time. please note above new enhancement might help a lot of Apple home and Google Home's routine and automation feature to make them possible This would save battery life and improve performance. I think these are all great ideas. I hope that Apple will consider implementing them in future versions of iOS and iPadOs and Watch OS. Thanks in advance. Best Pooya Mohammadhossein Pooya M
Posted
by
Post not yet marked as solved
1 Replies
775 Views
Hello, I have a few questions regarding the new CLMonitor that would be really helpful to hear answers to: How many conditions can the CLMonitor monitor at once? The analogous CLRegions had a limit of 20 in iOS 16. Is there a limit, or a larger limit with CLMonitor? What's the range of radii that CircularGeographicCondition can monitor? With CLRegions, we observed a functional minimum radius of 100m. Finally, the session video notes that CLMonitor events can arrive unpredictably: can any further elaboration be given on these events? When might there be more or less predictability of these events? Thanks! Liam
Posted
by
Post not yet marked as solved
1 Replies
567 Views
First of all : Thanks for the great presentation (wwdc2023-10180), Siraj ! This new, simple API looks like what we've been looking for for easy manageable background location updates with 'automatic battery drain minimization' :-) There were two questions that came to my mind. As far as I understood, the CLLocationUpdate.LiveConfiguration is used to help the location services to improve the location fixes. Are there other options planned to specify the granularity of delivered locations e.g., how accurate the locations need to be (as the desiredAccuracy and distanceFilter settings for the olden CLLocationManager)? Does the Implementation switch between significant location changes and regular, more expensive ways (like GPS hardware) or just deliver the most feasible accuracy available at the time of notification? I'm just curious - if I get the most feasible granularity, everything is fine for me anyway :-) Thanks again, Michael
Posted
by
Post not yet marked as solved
3 Replies
599 Views
When running Xcode 15.0 beta, and targeting watchOS 10.0, I'm getting the following error message when I invoke the object. I am using the line import CoreLocation at the top of my ContentView.swift directly below the line import SwiftUI. 'CLMonitor' is unavailable in watchOS
Posted
by
Post not yet marked as solved
2 Replies
662 Views
We are no longer getting a different value for trueHeading vs magneticHeading with the new ipad pro 6th generation M2 device. The M1 iPad Pro works and other iPad and iPhone devices work fine. Apple told one of our users that we need to update our app - but we did only 4 weeks ago. Has something changed to the use of the CLHeading api for the M2 chip?
Posted
by
Post not yet marked as solved
0 Replies
576 Views
I saw in https://developer.apple.com/videos/play/wwdc2023/10180/ at 12:51 that the CLBackgroundActivitySession will relaunch the app to resume location updates even if user closed the app (which I interpret to mean swiping the app from app switcher) -- despite the fact that the CLBackgroundActivitySession only require a when-in-use location permission. Since this api can give the app location updates even after the user swiped the app from the switcher, how is the api different than using the current always allow authorisation system to continuously record user movements? For the use case of continously tracking them whenever they move (let's say you wanted to record their driving behaviours), can't the app just launch the CLBackgroundActivitySession and continue to recreate this session every time the app is relaunched to keep on tracking?
Posted
by
Post not yet marked as solved
9 Replies
4.2k Views
hi, everyone! i travelled to a different time zone and the time has not updated to my new location. i seem to remember this worked ok before sonoma. system settings - privacy & security - location services - system services - details - setting time zone ON (if this is changed to off it does not stay off, if i leave that window pressing done, when i open that setting again it is still set to on, so changing it has no effect) system settings - general - date & time all set to ON (if Set time zone automatically using your current location is set to off the the Time zone stays greyed out and cannot be changed and only the Closest city can be changed, which is of no use as cities to select from are still not in the time zone i want to change to). this is probably a bug in the new macos sonoma and just wanted to make this known and hopefully have a solution to it. thank you!
Posted
by
Post not yet marked as solved
1 Replies
1.3k Views
I'm working on a weather and news app, and when I run the app on my device, it says "This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first." I am getting the error, what should I do? This error message appears on two lines with the CLLocationManager.locationServicesEnabled() else { method. I have added the codes of the page where I got the error below. I am using openweathermap API as weather API and newsapi API as news API. import Foundation import CoreLocation import Combine typealias LocationNameResultType = Result<String, Error> class WeatherService: WeatherServiceProtocol { private let apiProvider = APIProvider<WeatherEndpoint>() private let locationManager = CLLocationManager() private lazy var location: CLLocation? = locationManager.location init() { startUpdatingLocation() } func getCityName(completion: @escaping (LocationNameResultType) -> Void) { guard let location = location else { completion(.failure(WeatherServiceErrors.locationNil)) return } let geocoder = CLGeocoder() geocoder.reverseGeocodeLocation(location) { (placemarks, error) in if let error = error { completion(.failure(error)) } guard let placemark = placemarks?.first, let cityName = placemark.locality else { completion(.failure(WeatherServiceErrors.placeMarkNil)) return } completion(.success(cityName)) } } func requestCurrentWeather() -> AnyPublisher<Data, Error> { locationManager.requestWhenInUseAuthorization() guard CLLocationManager.locationServicesEnabled() else { return Fail(error: WeatherServiceErrors.userDeniedWhenInUseAuthorization) .eraseToAnyPublisher() } locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters locationManager.startUpdatingLocation() guard let location = location else { return Fail(error: WeatherServiceErrors.locationNil) .eraseToAnyPublisher() } return apiProvider.getData( from: .getCurrentWeather(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude) ) .eraseToAnyPublisher() } deinit { stopUpdatingLocation() } } private extension WeatherService { func startUpdatingLocation() { locationManager.requestWhenInUseAuthorization() guard CLLocationManager.locationServicesEnabled() else { return } locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters locationManager.startUpdatingLocation() } func stopUpdatingLocation() { locationManager.stopUpdatingLocation() } }
Posted
by
Post not yet marked as solved
0 Replies
511 Views
Hello, I have been working with Core Location to be able to obtain the location in real time, when the app is in the background and when it has been closed, but since the app is closed it is not possible to continue obtaining the location. These are my settings:
Posted
by
Post not yet marked as solved
0 Replies
347 Views
struct ImagePicker: UIViewControllerRepresentable { typealias UIViewControllerType = UIImagePickerController var sourceType: UIImagePickerController.SourceType var completionHandler: (UIImage?) -> Void func makeUIViewController(context: Context) -> UIImagePickerController { let imagePicker = UIImagePickerController() imagePicker.sourceType = sourceType imagePicker.delegate = context.coordinator return imagePicker } func updateUIViewController(_ uiViewController: UIImagePickerController, context: Context) { // No update needed } func makeCoordinator() -> Coordinator { Coordinator(completionHandler: completionHandler) } final class Coordinator: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate { private let completionHandler: (UIImage?) -> Void init(completionHandler: @escaping (UIImage?) -> Void) { self.completionHandler = completionHandler } func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { guard let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage else { completionHandler(nil) picker.dismiss(animated: true) return } completionHandler(image) picker.dismiss(animated: true) } func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { completionHandler(nil) picker.dismiss(animated: true) } } } var body: some View { TabView { // Page 1: Map Search // Page 2: Photos VStack { Spacer() Menu { Button(action: { showImagePicker = true selectedImageSourceType = .photoLibrary }) { Label("Choose from Library", systemImage: "photo") } Button(action: { showImagePicker = true selectedImageSourceType = .camera }) { Label("Take Photo", systemImage: "camera") } } label: { Text("Memories") .font(.title) .foregroundColor(.black) } .padding() .sheet(isPresented: $showImagePicker, onDismiss: loadImage) { ImagePicker(sourceType: selectedImageSourceType ?? .photoLibrary) { image in selectedImage = image } } .padding() .sheet(isPresented: $showImagePicker, onDismiss: loadImage) { ImagePicker(sourceType: selectedImageSourceType ?? .photoLibrary) { image in selectedImage = image } } if !images.isEmpty { ScrollView { LazyVGrid(columns: [GridItem(.adaptive(minimum: 200, maximum: 700))], spacing: 20) { ForEach(images, id: \.self) { image in Image(uiImage: image) .resizable() .aspectRatio(contentMode: .fill) .frame(height: UIScreen.main.bounds.height / 5) .frame(width: UIScreen.main.bounds.width - 60) .cornerRadius(15) } } .padding() } } else { Text("No photos available") .foregroundColor(.gray) } } .tabItem { Image(systemName: "camera") Text("Memories") } .tag(1) } .accentColor(.blue) } @State private var encodedAddress = "" func fetchLocationInfoFromWikipedia(for address: String) { guard let encodedAddress = address.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), let url = URL(string: "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro=true&explaintext=true&titles=\(encodedAddress)") else { self.encodedAddress = encodedAddress return } URLSession.shared.dataTask(with: url) { data, _, error in if let data = data { if let responseJSON = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any], let query = responseJSON["query"] as? [String: Any], let pages = query["pages"] as? [String: Any], let page = pages.keys.first, let pageData = pages[page] as? [String: Any], let extract = pageData["extract"] as? String { DispatchQueue.main.async { self.locationInfo = extract } } } } .resume() } func openWebsite(_ urlString: String) { if let encodedAddress = self.text.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), let url = URL(string: urlString + encodedAddress) { UIApplication.shared.open(url) } } func loadImage() { guard let selectedImage = selectedImage else { return } images.append(selectedImage) self.selectedImage = nil } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
Posted
by
Post not yet marked as solved
0 Replies
576 Views
The iOS'location service is used to track the accurate location of the user and the blue arrow become active and it show at the top of the screen. I want to question that : I want to develop an app which will receive location Update every 15 minutes by executing it at background mode. There is a way to hide the blue arrow between 1-15 minutes in order to make clear in the user that the app does not use the location service the time between 1-15 and only use it every 15 minutes to update it? Thank you very much, in advance!!
Posted
by
Post not yet marked as solved
0 Replies
460 Views
Some users of our App have a large range of drift in the case of high accuracy of positioning points during the static process, how to solve it. The CLLocationManager configuration is as follows.The desiredAccuracy is 3000.The distanceFilter is 1500.The location point horizontalAccuracy is less than 100,but the longitude and latitude of the positioning point are hundreds of kilometers different from the actual one.
Posted
by