다음 방법은 당신의 응용 프로그램을 깨울 것 :
- 지역 이벤트
- 방문 이벤트
- 중요한 위치 이벤트 귀하의 응용 프로그램과 함께 시작됩니다
위치 키는 applicationDidFinishLaunchingWithOptions
방법입니다. 다음 (http://nshipster.com/launch-options/에서) 정상적으로를 처리하는 방법에 대한 예는 다음과 같습니다 또한
// .h
@import CoreLocation;
@interface AppDelegate() <CLLocationManagerDelegate>
@property (readwrite, nonatomic, strong) CLLocationManager *locationManager;
@end
// .m
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
if (![CLLocationManager locationServicesEnabled]) {
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Location Services Disabled", nil)
message:NSLocalizedString(@"You currently have all location services for this device disabled. If you proceed, you will be asked to confirm whether location services should be reenabled.", nil)
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:nil] show];
} else {
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
[self.locationManager startMonitoringSignificantLocationChanges];
}
if (launchOptions[UIApplicationLaunchOptionsLocationKey]) {
[self.locationManager startUpdatingLocation];
}
}
, 당신은 당신이 다른 사용 사례에 대해 서로 다른 메커니즘을 사용할 수있는 등 중요한 위치 모니터링 또는 지역 모니터링을 사용하도록 제한되지 않습니다. 예 : 지역 모니터링을 사용하여 사용자 주변의 대체 지역을 설정하고 이탈 이벤트가 발생할 때마다 애플리케이션이 location
키를 사용하여 깨어납니다. 그런 다음 위치 서비스를 다시 시작할 수 있습니다.