Я добавил CLLocationManager в свое приложение, используя Swift в файле AppDelegate.
В файле Appdelegate.swift
import CoreLocation
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
var locationManager: CLLocationManager!
В методе didbecomeActive:
func applicationDidBecomeActive(application: UIApplication) {
if((locationManager) != nil)
{
locationManager.stopMonitoringSignificantLocationChanges()
locationManager.delegate = nil
locationManager = nil
}
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.activityType = CLActivityType.OtherNavigation
locationManager.requestAlwaysAuthorization()
locationManager.startMonitoringSignificantLocationChanges()
}
Если я использую startUpdatingLocation
, вызывается метод didUpdateLocations
, но не для startMonitoringSignificantLocationChanges
.
Почему его не вызывают на startMonitoringSignificantLocationChanges
. Я тестирую это в симуляторе ios. Я не знаю, как зарегистрировать устройство.