は、バックグラウンドで殺されても、アプリケーションを覚ますでしょう:
- 地域イベント
- ログインイベント
- 重要な場所イベント
はあなたのアプリケーションがで発売されますロケーションキーを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
キーで起動します。その後、ロケーションサービスを再開できます。