Hi,
I am unable to figure out how to request the users location via
requestWhenInUseAuthorization()
(resp. requestAlwaysAuthorization()
) just using code on the WatchKit Extention. After some Google research I found the question on StackOverflow: https://stackoverflow.com/questions/47543655/request-location-on-the-apple-watch-only-without-code-on-the-paired-phone , but as well without any usefull solution.What I did is, to set in the
Info.plist
all required keys (NSLocationWhenInUseUsageDescription
, and so on), as well on the iOS application and as well in the WatchKit Extention counterpart. The WatchKit Swift code snippet looks as follows:override func willActivate() {
super.willActivate()
locMgr.delegate = self
if CLLocationManager.authorizationStatus() == .notDetermined {
locMgr.requestWhenInUseAuthorization()
}
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
switch status {
case .authorizedWhenInUse :
print("authorizedWhenInUse")
....
}
}
The problem is, that the request dialog is never shown to the user. Neither on the Apple Watch nor on the iPhone and thus location service is not working. But in case I call
requestWhenInUseAuthorization()
on the iPhone counterpart, the request dialog is show and everything works perfectly. So, the question is, how to show the dialog without call requestWhenInUseAuthorization()
on iPhone?Thanks