Request location on the Apple Watch only, without code on the paired phone

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

Replies

I do it in viewDidLoad, with no test (if authorization already given, it is not requested again):


    override func viewDidLoad() {
       
        super.viewDidLoad()
       
        locationManager.delegate = self 
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.requestWhenInUseAuthorization()

That's the point, I don't want to call

requestWhenInUseAuthorization()
on the iPhone/iOS side, because I want to use the location just on the Apple Watch. Thus requesting the location ability shall be done on the watch. If I read your code correctly, then you do it on the iOS counterpart application which I want to avoid.

Were you ever able to get this working?


I've been trying it as well and can't get it to authorize without a direct request from code in the iPhone app counterpart.

Is that even possible? When an iPhone is connected the watch is getting its location updates from the iPhone. Or did you find a way to always use the GPS chip on the watch. Even when an iPhone is connected. Please let me know. I still not found a way to do this. (I suspect that it is impossible)