Giter Site home page Giter Site logo

locationmanager's Introduction

INTULocationManager

Build Status Test Coverage Version Platform License

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

  1. Add the pod INTULocationManager to your Podfile.
pod 'INTULocationManager'
  1. Run pod install from Terminal, then open your app's .xcworkspace file to launch Xcode.
  2. Import the INTULocationManager.h header.
  • With use_frameworks! in your Podfile
    • Swift: import INTULocationManager
    • Objective-C: #import <INTULocationManager/INTULocationManager.h> (or with Modules enabled: @import INTULocationManager;)
  • Without use_frameworks! in your Podfile
    • Swift: Add #import "INTULocationManager.h" to your bridging header.
    • Objective-C: #import "INTULocationManager.h"

Using Carthage

  1. Add the intuit/LocationManager project to your Cartfile.
github "intuit/LocationManager"
  1. Run carthage update, then follow the additional steps required to add the iOS and/or Mac frameworks into your project.
  2. Import the INTULocationManager framework/module.
  • Swift: import INTULocationManager
  • Objective-C: #import <INTULocationManager/INTULocationManager.h> (or with Modules enabled: @import INTULocationManager;)

Manually from GitHub

  1. Download all the files in INTULocationManager subdirectory.
  2. Add the source files to your Xcode project (drag and drop is easiest).
  3. Import the INTULocationManager.h header.
  • 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 {
                                             // An error occurred, more info is available by looking at the specific status returned.
                                         }
                                     }];
let locationManager = INTULocationManager.sharedInstance()
locationManager.requestLocation(withDesiredAccuracy: .city,
                                            timeout: 10.0,
                               delayUntilAuthorized: true) { (currentLocation, achievedAccuracy, status) in
                                   if (status == INTULocationStatus.success) {
                                       // Request succeeded, meaning achievedAccuracy is at least the requested accuracy, and
                                       // currentLocation contains the device's current location
                                   }
                                   else if (status == INTULocationStatus.timedOut) {
                                       // 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 {
                                       // An error occurred, more info is available by looking at the specific status returned.
                                   }
           }

Subscribing to Continuous Location Updates

To subscribe to continuous location updates, use the method subscribeToLocationUpdatesWithBlock:. This method instructs location services to use the highest accuracy available (which also requires the most power). The block will execute indefinitely (even across errors, until canceled), once for every new updated location regardless of its accuracy.

If you do not need the highest possible accuracy level, you should instead use subscribeToLocationUpdatesWithDesiredAccuracy:block:. This method takes the desired accuracy level and uses it to control how much power is used by location services, with lower accuracy levels like Neighborhood and City requiring less power. Note that INTULocationManager will automatically manage the system location services accuracy level, including when there are multiple active location requests/subscriptions with different desired accuracies.

If an error occurs, the block will execute with a status other than INTULocationStatusSuccess, and the subscription will be kept alive.

Here's an example:

INTULocationManager *locMgr = [INTULocationManager sharedInstance];
[locMgr subscribeToLocationUpdatesWithDesiredAccuracy:INTULocationAccuracyHouse
                                                block:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) {
                                                    if (status == INTULocationStatusSuccess) {
                                                        // A new updated location is available in currentLocation, and achievedAccuracy indicates how accurate this particular location is.
                                                    }
                                                    else {
                                                        // An error occurred, more info is available by looking at the specific status returned. The subscription has been kept alive.
                                                    }
                                                }];

Subscribing to Significant Location Changes

To subscribe the significant location changes, use the method subscribeToSignificantLocationChangesWithBlock:. This instructs the location services to begin monitoring for significant location changes, which is very power efficient. The block will execute indefinitely (until canceled), once for every new updated location regardless of its accuracy. Note that if there are other simultaneously active location requests or subscriptions, the block will execute for every location update (not just for significant location changes). If you intend to take action only when the location has changed significantly, you should implement custom filtering based on the distance & time received from the last location.

If an error occurs, the block will execute with a status other than INTULocationStatusSuccess, and the subscription will be kept alive.

Here's an example:

INTULocationManager *locMgr = [INTULocationManager sharedInstance];
[locMgr subscribeToSignificantLocationChangesWithBlock:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) {
    if (status == INTULocationStatusSuccess) {
		// A new updated location is available in currentLocation, and achievedAccuracy indicates how accurate this particular location is.
    }
    else {
        // An error occurred, more info is available by looking at the specific status returned. The subscription has been kept alive.
    }
}];

If your app has acquired the "Always" location services authorization and your app is terminated with at least one active significant location change subscription, your app may be launched in the background when the system detects a significant location change. Note that when the app terminates, all of your active location requests & subscriptions with INTULocationManager are canceled. Therefore, when the app launches due to a significant location change, you should immediately use INTULocationManager to set up a new subscription for significant location changes in order to receive the location information.

Here is an example of how to handle being launched in the background due to a significant location change:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // If you start monitoring significant location changes and your app is subsequently terminated, the system automatically relaunches the app into the background if a new event arrives.
    // Upon relaunch, you must still subscribe to significant location changes to continue receiving location events. 
    if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]) {
        INTULocationManager *locMgr = [INTULocationManager sharedInstance];
        [locMgr subscribeToSignificantLocationChangesWithBlock:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) {
            // This block will be executed with the details of the significant location change that triggered the background app launch,
            // and will continue to execute for any future significant location change events as well (unless canceled).
        }];
    }
    return YES;
}

Managing Active Requests or Subscriptions

When issuing a location request, you can optionally store the request ID, which allows you to force complete or cancel the request at any time:

INTULocationManager *locMgr = [INTULocationManager sharedInstance];
INTULocationRequestID requestID = [locMgr requestLocationWithDesiredAccuracy:INTULocationAccuracyHouse
                                                                     timeout:5.0
                                                                       block:locationRequestBlock];

// Force the request to complete early, like a manual timeout (will execute the block)
[[INTULocationManager sharedInstance] forceCompleteLocationRequest:requestID];

// Cancel the request (won't execute the block)
[[INTULocationManager sharedInstance] cancelLocationRequest:requestID];

Note that subscriptions never timeout; calling forceCompleteLocationRequest: on a subscription will simply cancel it.

Subscribing to Continuous Heading Updates

To subscribe to continuous heading updates, use the method subscribeToHeadingUpdatesWithBlock:. This method does not set any default heading filter value, but you can do so using the headingFilter property on the manager instance. It also does not filter based on accuracy of the result, but rather leaves it up to you to check the returned CLHeading object's headingAccuracy property to determine whether or not it is acceptable.

The block will execute indefinitely (until canceled), once for every new updated heading regardless of its accuracy. Note that if heading requests are removed or canceled, the manager will automatically stop updating the device heading in order to preserve battery life.

If an error occurs, the block will execute with a status other than INTUHeadingStatusSuccess, and the subscription will only be automatically canceled if the device doesn't have heading support (i.e. for status INTUHeadingStatusUnavailable).

Here's an example:

INTULocationManager *locMgr = [INTULocationManager sharedInstance];
[locMgr subscribeToHeadingUpdatesWithBlock:^(CLHeading *heading, INTUHeadingStatus status) {
    if (status == INTUHeadingStatusSuccess) {
        // An updated heading is available
        NSLog(@"'Heading updates' subscription block called with Current Heading:\n%@", heading);
    } else {
        // An error occurred, more info is available by looking at the specific status returned. The subscription will be canceled only if the device doesn't have heading support.
    }
}];

Example Project

Open the project included in the repository (requires Xcode 6 and iOS 8.0 or later). It contains a LocationManagerExample scheme that will run a simple demo app. Please note that it can run in the iOS Simulator, but you need to go to the iOS Simulator's Debug > Location menu once running the app to simulate a location (the default is None).

Issues & Contributions

Please open an issue here on GitHub if you have a problem, suggestion, or other comment.

Pull requests are welcome and encouraged! There are no official guidelines, but please try to be consistent with the existing code style.

License

INTULocationManager is provided under the MIT license.

INTU on GitHub

Check out more iOS and OS X open source projects from Intuit!

locationmanager's People

Contributors

andychenw avatar d4r1091 avatar dcortright avatar evfemist avatar iminichrispy avatar jhall15 avatar krstnfx avatar laizaraujo avatar lwdupont avatar orta avatar ruslanskorb avatar sanyampunia avatar skandakov avatar smileyborg avatar thekie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

locationmanager's Issues

iPhone5c(iOS7) iPhone4s(iOS7) Example problems

iPhone5c(iOS7) iPhone4s(iOS7) Example problems
The Simulator is well, but problems with real device.
Unable to get the latitude and longitude

Debug Infomation:
2015-02-07 15:39:18.164 LocationManagerExample[766:4207] readValue0 = 1
2015-02-07 15:39:18.166 LocationManagerExample[766:4207] latitude = 30.679545 longitude = 111.308235
2015-02-07 15:39:18.168 LocationManagerExample[766:60b] not respondsToSelector
2015-02-07 15:39:19.171 LocationManagerExample[766:4207] readValue0 = 1
2015-02-07 15:39:19.173 LocationManagerExample[766:4207] latitude = 30.679545 longitude = 111.308235
2015-02-07 15:39:19.175 LocationManagerExample[766:60b] not respondsToSelector
2015-02-07 15:39:20.178 LocationManagerExample[766:4207] readValue0 = 1
2015-02-07 15:39:20.180 LocationManagerExample[766:4207] latitude = 30.679545 longitude = 111.308235
2015-02-07 15:39:20.182 LocationManagerExample[766:60b] not respondsToSelector

Feature Request: Configurable Location Update Frequency

I would like to be able to set a frequency for location updates, and retrieve the last known location.

In my case, I need to access the location information in my UISearchResultsUpdater but I don't want to actually make a location request every time the user types a character. I'd like to be able to limit it so the location actually only updates once every 2 minutes or so, and other wise, calls the completion block immediately, returning the last known location.

This would be easier if the currentLocation property was made public. It would be nice to seem some frequency limiting features in the library internally, but if I can access currentLocation, I could at least use something like Rate Limit (https://github.com/soffes/RateLimit) to limit my location updates and then just grab the current location.

Thoughts?

blocking the main thread

INTULocationManager *locMgr = [INTULocationManager sharedInstance];
[locMgr requestLocationWithDesiredAccuracy:INTULocationAccuracyBlock
timeout:10.0
delayUntilAuthorized:NO // This parameter is optional, defaults to NO if omitted
block:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) {

                                     }];

Undefined symbols for architecture x86_64:

Hi,

I am new to iOS programming. As I added the Source files onto my Xcode project, i encountered the following errors when compiling. Any suggestions?

Undefined symbols for architecture x86_64:

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_CLLocationManager", referenced from:
objc-class-ref in INTULocationManager.o
"_kCLLocationAccuracyBest", referenced from:
-[INTULocationManager startUpdatingLocationIfNeeded] in INTULocationManager.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

bug while using library

To use location services in iOS 8+, your Info.plist must provide a value for either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription.

Getting Current Location (Once)

I am using the function that gets the current location. If i close my phone for some time and then open it and start my application it cant get any location. if i run the app again from xcode then it return a location. why is that happening?

location is callback,but the status is INTULocationStatusTimedOut

  • requestLocationWithDesiredAccuracy:(INTULocationAccuracy)desiredAccuracy
    timeout:(NSTimeInterval)timeout
    block:(INTULocationRequestBlock)block
    I use this method the block is called and I got log "INTULocationManager: Location Request completed with ID: 1, currentLocation: <+39.89284587,+116.16985747> +/- 65.00m (speed -1.00 mps / course -1.00) @ 15/12/12 **标准时间 上午10:10:48, achievedAccuracy: 3, status: 1",but the block status is INTULocationStatusTimedOut.

Better location services availability reporting

Hi,

As you know since iOS 8 we are able to open privacy settings directly via openURL. So to avoid frustration developers now can display instructions how to enable location services whether system or app wide and basically take user to privacy settings in latter case.

It would be great to add methods that could report current status of authorization granted to the app or whether location services are disabled on device.

Would it be possible to adapt code below for INTULocationManager and would you like to include such methods in your Pod?

@implementation INTULocationManager (AuthorizationStatus)

// whether location services are enabled on device
// e.g. I use it show alert to user that explains how to open settings and flip that switch
+ (BOOL)locationServicesEnabled {
    return [CLLocationManager locationServicesEnabled];
}

// whether first time permissions request was sent
// Usually I use it in combination with authorizedForLocationServices to understand 
// whether I should show instructions on how to enable location services 
// in case when user denied access in the first place.
+ (BOOL)shouldRequestAuthorization {
    return ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined);
}

// whether app is authorized to use location services
+ (BOOL)authorizedForLocationServices {
    CLAuthorizationStatus authorizationStatus = [CLLocationManager authorizationStatus];
    return (authorizationStatus == kCLAuthorizationStatusAuthorizedAlways || authorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse);
}

@end

Thanks you.

requestLocation when application is in background

Hi and Thanks for this pod!

I have a timer that call requestLocationWithDesiredAccuracy every X minutes depending if the user is walking, running, etc...

However, how can I call this same method when my application is in background ?

[feature] Knowing the user general location without asking for permission.

A nice feature to have in this class is the ability to identify the user general location (country) without asking for permission. Something like a desiredAccuracy of INTULocationAccuracyCountry. This can be done in a number of ways but the best I can think of is to use something like http://www.iplocationtools.com/ or any other free service that offers to translate an IP address to a country. (And of course without using Core Location)

Services like Spotify etc' that are country based always using something like that in order to know the user location without asking for permission.

TableView Freezez

Hi,
I am using purelayout to populate cells in UiTableView. But whenever there is a height calculation in cellforrowatindexpath, it freezes the view. Is there any way to resolve this ?

Expose CLLocationManagerDelegate protocol implementation

I have a subclass of INTULocationManager in which I'd like to perform some additional setup when location authorisation changes, however I can't override and then call super's locationManager:didChangeAuthorizationStatus: because INTULocationManager implements the CLLocationManager protocol in it's empty category interface rather than the class interface itself. Can this be changed?

Finding current location in background.

Finding current location in background.

INTULocationManager *locMgr = [INTULocationManager sharedInstance];
    [locMgr requestLocationWithDesiredAccuracy:INTULocationAccuracyBlock
                                       timeout:10.0
                          delayUntilAuthorized:NO  // This parameter is optional, defaults to NO if omitted
                                         block:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status) {


                                         }];

this is code, locks the mainthread.

Possible convenience subscription to heading and location?

Something I do in my current app (and I imagine is done in a few apps that use location) is to subscribe to both heading and location updates in order to display a compass pointing to a particular location.

You need both the current location and the current heading in order to do this.

Do you think it would be worth adding a convenience subscription that returns both the location and heading in a single block?

Subscription to location updates can lead to excessive battery usage

If i make a subscription to get regular position updates, the requests are never emptied thus the location manager is always running. And it is always running in the mode desiredAccuracy kCLLocationAccuracyBest. But i don't need this accuracy which needs so much battery power. I have no option to change to desiredAccuracy.

[Feature] Adding of the significant location change to this class.

This class can add a significant location feature - battery saving mode, including the background scenarios of the significant location where app is wake up in background on location change to process the data in few seconds.

This mark as the complete solution to location manager.

ip fallback location

if the use didnt allow the location permission , can you plz add a fallback location based on ip perexample

The block never gets called

It was working fine, but at some point it just started not to call the block any longer. I can´t even look at the status value. I only get these in the log:

INTULocationManager: Changing location services accuracy level to: medium.
INTULocationManager: Location services updates have started.
INTULocationManager: Location Request added with ID: 1

I have tested calling it once:

[locMgr requestLocationWithDesiredAccuracy:INTULocationAccuracyBlock
timeout:10.0
delayUntilAuthorized:YES // This parameter is optional, defaults to NO if omitted
block:^(CLLocation *currentLocation, INTULocationAccuracy achievedAccuracy, INTULocationStatus status);

Testing on device with IOS 9.1. Also have added the necessary key in info.plist to get authorization. Using latest released version 4.1.1 (also 4.0.0).

Any ideas what may be wrong?

Bug when requesting permissions

When requesting permissions from user the alert popup show for 1 seconds and then disappear
When i implement in Apple regular code the alert popup doesn't disappear

All location requests canceled upon the first error

I may be misunderstanding the intent, but it appears all location requests (including all subscriptions) get immediately canceled and removed as soon as there is a single error. Shouldn't it be keeping around subscriptions, regardless of whether there are intermittent errors?

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    INTULMLog(@"Location services error: %@", [error localizedDescription]);
    self.updateFailed = YES;

    [self completeAllLocationRequests];
}

which eventually calls

- (void)completeLocationRequest:(INTULocationRequest *)locationRequest
{
    if (locationRequest == nil) {
        return;
    }

    [locationRequest complete];
    [self removeLocationRequest:locationRequest];

    // more stuff
}

Seems like you'd wanna process all location requests, since that has conditional handling for subscriptions and completing them if necessary:

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    INTULMLog(@"Location services error: %@", [error localizedDescription]);
    self.updateFailed = YES;

    [self processLocationRequests];
}

The only other issue I see is that you are also potentially canceling the subscription in there if the request timed out, rather than keeping it alive and just waiting for a success response:

- (void)processLocationRequests
{
    CLLocation *mostRecentLocation = self.currentLocation;

    for (INTULocationRequest *locationRequest in self.locationRequests) {
        if (locationRequest.hasTimedOut) {
            // Request has timed out, complete it
            [self completeLocationRequest:locationRequest];
            continue;
        } 

        // more conditionals for subscriptions versus one-off requests
}

No background updates?

Hi there,

Thanks for this library. subscribeToLocationUpdatesWithDesiredAccuracy you introduced recently is a long-awaited and great feature.

I'm subscribing to desired accuracy update in didFinishLaunchingWithOptions app delegate. NSLocationAlwaysUsageDescription is set in the property list and location updates is activated in background modes.

I opted in to receive location updates even in background. But, when the app goes to the background, I no longer receive updates, with no further log. As soon as it is in the foreground I get them back.

What did I miss? Does background mode only work with subscribeToSignificantLocationChangesWithBlock?

Thanks for your help.

Make public requestAuthorizationIfNeeded

In iOS 8 and later the maps need the request for showing an user location. Can you make requestAuthorizationIfNeeded from private to public? It would be convenient :)

INTULocationManagerVersionNumber

why exists INTULocationManagerVersionNumber and INTULocationManagerVersionString ,
but not be used in file INTULocationManager.h line:29

Slow Location Results

I request the user's location on app launch it it sometimes takes several minutes to get the location. I am in the middle of the city and other apps are working just fine with location. Have you hit this issue before and is it library related?

Always error when try to locate GPS on the Simulator.

Hi there,
Thanks for your library it is very helpful for me.

After I upgrade Xcode IDE to latest version 6.1 it does not work smoothly, when I run on a real iDevice your library works good (iOS 7 and iOS 8) but on the simulator it's alway return case INTULocationStatusError

My project was setup to simulate the location, the simulator have some gpx files to switch other locations.

please help,

Crash because of changing array while iterating over it

When i use the lib it crashes, it crashes in the processLocationRequests method in the for-loop. The error is the mutation of the array self.locations and at the same time using self.locations in this loop. I fixed it by making a copy of self.locations and use this copy for the loop:

NSArray *locationRequests = [self.locationRequests copy];
for (INTULocationRequest *locationRequest in locationRequests) {
... 

Add ability to subscribe to location updates

The current API is designed for single, one-time location requests. However, it would be great to have an API that also provided a block-based mechanism to create a subscription for location updates. This would support use cases like turn-by-turn navigation and other real-time usage of location services, but without having to use CLLocationManager directly and sharing nearly all of the internals of the existing component.

Does this lib support CLHeading?

Does this lib support CLHeading?
I want to create a compass that points to a location (not to the north), so apart from the current location I need the current heading.
Otherwise, any recommendation of another location manager?
Thanks in advance!

Unknown type name 'CGFloat'

When i pod update and build, i failed and get the message "unknown type name 'CGFloat'" in INTULocationDefines.h. I don't know how to fix it, ty.
The problem code is: static const CGFloat kINTUHorizontalAccuracyThresholdCity = 5000.0;

I fix the bug when i add "~>1.0" in my podfile. But why it didn't work in 2.0.0 version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.