The other answers are incorrect. You can request location directly on the watch for watch OS2. The available method is called requestLocation
. It allows you to request a single location update.
E.g.
#import <CoreLocation/CoreLocation.h>
@interface className : WKInterfaceController<CLLocationManagerDelegate>
Then where you want to request location:
self.locationManager = [CLLocationManager new];
self.locationManager.delegate = self;
[self.locationManager requestWhenInUseAuthorization];
[self.locationManager requestLocation];
Then you will get a single callback in one of the following CLLocationManagerDelegate
methods.
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
// Callback here with single location if location succeeds
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
// Error here if no location can be found
}
See the WWDC15 video "What's New in Core Location" - https://developer.apple.com/videos/wwdc/2015/?id=714
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…