It's a CoreLocation wrapper
(singleton) to allow an internal use overall your application.
Call [JFELocationManager sharedInstance];
in your AppDelegate file or somewhere else to initiate the singleton and automatically starting to update location and heading
JFELocationManager is now ready for iOS 8. To enable the library you have to add a new entry in you Info.plist
file.
NSLocationAlwaysUsageDescription = "The message to be shown";
Set a controller as
@interface JFEViewController : UIViewController<JFELocationManagerDelegate>
Then you can implement each (or one) of these delegate methods:
-(void) didUpdateHeading:(CLHeading *)newHeading;
-(void) didUpdateLocation:(CLLocation*) location;
-(void) didChangeAuthorizationStatus:(CLAuthorizationStatus)status;
To allow background updates you have to define those methods in your appdelegate
file
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// ... Do something else ...
// Force to disable the location update only if there is no "important delegate"
if ([JFELocationManager sharedInstance].importantDelegate == nil) {
NSLog(@"AppDelegate -> I disable updating location");
[[JFELocationManager sharedInstance] stop];
}
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// ... Do something else ...
if ([JFELocationManager sharedInstance].importantDelegate == nil) {
[[JFELocationManager sharedInstance] start];
NSLog(@"AppDelegate -> I enable updating location");
}
}
iOS 6.0 and later.
Add JFELocationManager.h/m
into your project, or pod 'JFELocationManager'
using CocoaPods.
Jerome Freyre, jerome.freyre@gmail.com
JFELocationManager is available under the MIT license. See the LICENSE file for more info.