SLC , , , , CLLocationManager startMonitoringSignificantLocationChanges. - iOS7.0 (.x) . iOS7.1 +.
.
- , .
- NSLocationAlwaysUsageDescription info.plist, , .
- ,
- ,
- .
:
AppDelegate,
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, CLLocationManagerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property CLLocationManager* locationMgr;
@end
AppDelegate.m
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize locationMgr;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"app launching");
locationMgr = [[CLLocationManager alloc] init];
[locationMgr setDelegate:self];
if([locationMgr respondsToSelector:@selector(requestAlwaysAuthorization)])
[locationMgr requestAlwaysAuthorization];
if([locationMgr respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)])
[locationMgr setAllowsBackgroundLocationUpdates:YES];
[locationMgr startMonitoringSignificantLocationChanges];
return YES;
}
-(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"app delegate received significant location change");
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:[[UIApplication sharedApplication] applicationIconBadgeNumber]+1];
}
@end
"", , . "" , . , , , , . .
iOS SLC.
. CLLocationManager startMonitoringSignificantLocationChanges , stopMonitoringSignificantLocationChanges. , CLLocationManager SLC, , - , .
, .
, , , - SLC.
start, start, stop start, exit - SLC.