LocationManager
Easily get the device's current location on iOS.
Install / Use
/learn @intuit/LocationManagerREADME
INTULocationManager makes it easy to get the device's current location and is currently heading on iOS. It is an Objective-C library that also works great in Swift.
INTULocationManager provides a block-based asynchronous API to request the current location, either once or continuously. It internally manages multiple simultaneous locations and heading requests, and each one-time location request can specify its own desired accuracy level and timeout duration. INTULocationManager automatically starts location services when the first request comes in and stops the location services when all requests have been completed, while dynamically managing the power consumed by location services to reduce the impact on battery life.
What's wrong with CLLocationManager?
CLLocationManager requires you to manually detect and handle things like permissions, stale/inaccurate locations, errors, and more. CLLocationManager uses a more traditional delegate pattern instead of the modern block-based callback pattern. And while it works fine to track changes in the user's location over time (such as, for turn-by-turn navigation), it is extremely cumbersome to correctly request a single location update (such as to determine the user's current city to get a weather forecast, or to autofill an address from the current location).
INTULocationManager makes it easy to request both the device's current location, either once or continuously, as well as the device's continuous heading. The API is extremely simple for both one-time location requests and recurring subscriptions to location updates. For one-time location requests, you can specify how accurate of a location you need, and how long you're willing to wait to get it. Significant location change monitoring is also supported. INTULocationManager is power efficient and conserves the device's battery by automatically determining and using the most efficient Core Location accuracy settings, and by automatically powering down location services (e.g. GPS or compass) when they are no longer needed.
Installation
INTULocationManager requires iOS 9.0 or later.
Using CocoaPods
- Add the pod
INTULocationManagerto your Podfile.
pod 'INTULocationManager'
- Run
pod installfrom Terminal, then open your app's.xcworkspacefile to launch Xcode. - Import the
INTULocationManager.hheader.
- With
use_frameworks!in your Podfile- Swift:
import INTULocationManager - Objective-C:
#import <INTULocationManager/INTULocationManager.h>(or with Modules enabled:@import INTULocationManager;)
- Swift:
- Without
use_frameworks!in your Podfile- Swift: Add
#import "INTULocationManager.h"to your bridging header. - Objective-C:
#import "INTULocationManager.h"
- Swift: Add
Using Carthage
- Add the
intuit/LocationManagerproject to your Cartfile.
github "intuit/LocationManager"
- Run
carthage update, then follow the additional steps required to add the iOS and/or Mac frameworks into your project. - Import the INTULocationManager framework/module.
- Swift:
import INTULocationManager - Objective-C:
#import <INTULocationManager/INTULocationManager.h>(or with Modules enabled:@import INTULocationManager;)
Manually from GitHub
- Download all the files in INTULocationManager subdirectory.
- Add the source files to your Xcode project (drag and drop is easiest).
- Import the
INTULocationManager.hheader.
- Swift: Add
#import "INTULocationManager.h"to your bridging header. - Objective-C:
#import "INTULocationManager.h"
Usage
Requesting Permission to Access Location Services
INTULocationManager automatically handles obtaining permission to access location services when you issue a location request and the user has not already granted your app the permission to access that location services.
iOS 9 and above
Starting with iOS 8, you must provide a description for how your app uses location services by setting a string for the key NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in your app's Info.plist file. INTULocationManager determines which level of permissions to request based on which description key is present. You should only request the minimum permission level that your app requires, therefore it is recommended that you use the "When In Use" level unless you require more access. If you provide values for both description keys, the more permissive "Always" level is requested.
iOS 11
Starting with iOS 11, you must provide a description for how your app uses location services by setting a string for the key NSLocationAlwaysAndWhenInUseUsageDescription in your app's Info.plist file.
iOS 12
Starting with iOS 12, you will have access to set the desiredActivityType as CLActivityTypeAirborne.
Getting the Current Location (once)
To get the device's current location, use the method requestLocationWithDesiredAccuracy:timeout:block:.
The desiredAccuracy parameter specifies how accurate and recent of a location you need. The possible values are:
INTULocationAccuracyCity // 5000 meters or better, received within the last 10 minutes -- lowest accuracy
INTULocationAccuracyNeighborhood // 1000 meters or better, received within the last 5 minutes
INTULocationAccuracyBlock // 100 meters or better, received within the last 1 minute
INTULocationAccuracyHouse // 15 meters or better, received within the last 15 seconds
INTULocationAccuracyRoom // 5 meters or better, received within the last 5 seconds -- highest accuracy
The desiredActivityType parameter indicated the type of activity that is being tracked. The possible values are:
CLActivityTypeFitness // Track fitness activities such as walking, running, cycling, and so on
CLActivityTypeAutomotiveNavigation // Track location changes to the automobile
CLActivityTypeAirborne // Track airborne activities - iOS 12 and above
CLActivityTypeOtherNavigation // Track vehicular navigation that are not automobile related
CLActivityTypeOther // Track unknown activities. This is the default value
The timeout parameter specifies that how long you are willing to wait for a location with the accuracy you requested. The timeout guarantees that your block will execute within this period of time, either with a location of at least the accuracy you requested (INTULocationStatusSuccess), or with whichever location could be determined before the timeout interval was up (INTULocationStatusTimedOut). Pass 0.0 for no timeout (not recommended).
By default, the timeout countdown begins as soon as the requestLocationWithDesiredAccuracy:timeout:block: method is called. However, there is another variant of this method that includes a delayUntilAuthorized: parameter, which allows you to pass YES to delay the start of the timeout countdown until the user has responded to the system location services permissions prompt (if the user hasn't allowed or denied the app access yet).
Here's an example:
INTULocationManager *locMgr = [INTULocationManager sharedInstance];
[locMgr requestLocationWithDesiredAccuracy:INTULocationAccuracyCity
timeout:10.0
delayUntilAuthorized:YES // This parameter is optional, defaults to NO if omitted
block:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) {
if (status == INTULocationStatusSuccess) {
// Request succeeded, meaning achievedAccuracy is at least the requested accuracy, and
// currentLocation contains the device's current location.
}
else if (status == INTULocationStatusTimedOut) {
// Wasn't able to locate the user with the requested accuracy within the timeout interval.
// However, currentLocation contains the best location available (if any) as of right now,
// and achievedAccuracy has info on the accuracy/recency of the location in currentLocation.
}
else {
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。

