iOS 11.3, Watch OS 4.3: узнать текущее местоположение пользователя в watchOS 4.3? - PullRequest
0 голосов
/ 02 мая 2018

Я пробовал это в быстрой

Как узнать текущее местоположение в watchOS 2?

Но это не работает Вот мой код в WKInterfaceController

override func awake(withContext context: Any?) {
    super.awake(withContext: context)
    self.setupLocation()
}

extension InterfaceController: CLLocationManagerDelegate {

    func setupLocation() {
        self.locationManager.delegate = self
        self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
        self.locationManager.requestWhenInUseAuthorization()
        self.locationManager.startUpdatingLocation()
    }

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        guard let currentLocation = locations.first else { return }
        self.currentLocation = currentLocation
        let location = "lat: \(self.currentLocation.coordinate.latitude)\nlong: \(self.currentLocation.coordinate.longitude)"
        self.locationLabel.setText(location)
    }

    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
        print("LOCATION MANAGER DID FAIL ERROR : \(error)")
    }
}

Я добавил разрешение в WatchExtension и Основное приложение info.plist.

Это все еще даже не спрашивает разрешения оповещения. Что мне не хватает ???? (

...