WatchKit and Core Location Not Requesting User Permission

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


WatchKit and Core Location Not Requesting User Permission



enter image description here



I cannot get location services on WatchOS 4 to request user permission.



My info.plist with privacy usage description in WatchKit Extension is above.



My code is below. When it is run, no authorization is requested and I don't get any location updates.


private let locationManager = CLLocationManager()

override func willActivate() {
super.willActivate()

locationManager.allowsBackgroundLocationUpdates = true
locationManager.delegate = self
self.locationManager.requestWhenInUseAuthorization()

}
func locationServicesAuthorizationStatus(_ status: CLAuthorizationStatus) {
locationManager.requestWhenInUseAuthorization()
switch status {
case .notDetermined:
print("LocationServicesAuthorizationStatus: .notdetermined")
self.locationManager.requestWhenInUseAuthorization()
locationServicesStateNotDetermined()
case .restricted, .denied:
print("LocationServicesAuthorizationStatus: .restricted, .denied")
locationServicesStateUnavailable()
case .authorizedAlways, .authorizedWhenInUse:
print("LocationServicesAuthorizationStatus: .authorizedAlways, .authorizedWhenInUse")
locationServicesStateAvailable(status)
}
}

func locationServicesStateAvailable(_ status: CLAuthorizationStatus) {

switch status {
case .authorizedAlways:
print("Always in Use Granted")
locationManager.requestLocation()
case .authorizedWhenInUse:
print("When in Use Granted")

default:
break
}
}
func locationServicesStateUnavailable() {
print("Location Services unavailable")

}
func locationServicesStateNotDetermined() {
print("In Handle Not Determined")
locationManager.requestWhenInUseAuthorization()
}



I am not using the iPhone app location services. I only want to use the WatchOS core location.



The remainder of my location services is implemented as an extension:


extension InterfaceController: CLLocationManagerDelegate {

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
DispatchQueue.main.async {
print("nlocation obtainedn")

let altitudeString = Altitude(tofeet: locations[0].altitude)

NotificationCenter.default.post(name: Notification.Name(rawValue: "GetLocationRequest"), object: self, userInfo: ["altitude":altitudeString.inLocalUnits])
print("n 1.0 *** location update (Using locationManager.requestLocation) from watch location manager: (locations) n")

}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error.localizedDescription)
print("n Request for Location Failed. Location Services may try again")

}



Looking for an answer drawing from credible and/or official sources.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

m2sp rrPy,B1 ztOOGD 2fCUsGGVzk
9zAvlYFaosvp55DxSSWJ9jHIN7uHm7tE p,BnjREUb

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham