Is it possible to make CLLocationManager calls in a Custom Intent Extension (on iOS)?
If so, is there some special configuration (info.plist etc) necessary as I can't get it to work (as it's for example done in a Today Extension).
Thank you.
Is it possible to make CLLocationManager calls in a Custom Intent Extension (on iOS)?
If so, is there some special configuration (info.plist etc) necessary as I can't get it to work (as it's for example done in a Today Extension).
Thank you.
Hi,
Same question. I have to calculate distance for the intent's response,
but CLLocationManager seems unusable in Intent Ext
1- Intent Handler is not in main thread
2 - life time of intent seems too short to create manager/perform location/release manager
Informations are welcome
Thanks
I seem to have got it to work, but it often will time out unless the accuracy is set to very low. I'm not sure what the best way of doing this is.
It can be called by dispatching on the main thread:
dispatch_sync(dispatch_get_main_queue(), ^{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
[self.locationManager requestWhenInUseAuthorization];
[self.locationManager requestLocation];
});
Does anyone else know what the preferred way of doing this us, or even if it is expected to work?
This example from Apple shows CLLocationManager being used in an IntentHandler confirm() method. Though they are just checking permissions in this example, it is encouraging to see Core Location being used in an Intent Extension.
Re: your code snippet above, if your Intent supports background execution, you should probably avoid performing requestAuthorization in the handler. If the user hasn't already made a permission choice, the permission dialog flow doesn't appear to work properly when requested in this manner.
The problem is that core location must be created in the main thread. Just create the CLLocationManager in the main thread.