CLLocationManagerDelegate not working on Siri Intents

I need to elicit the location of the user in the Siri intents and so I call:

override init(){ super.init() self.locationManager=CLLocationManager() self.locationManager.delegate = self; self.locationManager.startUpdatingLocation() self.locationManager.requestWhenInUseAuthorization() }

Still neither

public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager)

nor

public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) are ever called, notwithstanding the presence of the correct entry in the info.plist, the inclusion of the library and the indication of the delegation with:

class IntentHandler: INExtension, INSendMessageIntentHandling, CLLocationManagerDelegate, UISceneDelegate

are ever called.

Is there any problem with CLLocation manager on intents? What would be a big problem as there is no way to share information with the main app!

The SiriKit extension point is fairly short lived, so one of the most common issues I've seen is that execution through your resolution and handling methods is complete and the process destroyed before the system has time to inform your app of location information through the delegate.

For permission, it'd be better to have location access already granted in the main app. Along the lines of short timeline for these extension processes to execute, there's not a reasonable amount of time for the customer to evaluate your request for location and approve or deny it.

I also see your IntentHandler has conformance to UISceneDelegate, which is a set up I've never seen before. Would you mind sharing a more complete implementation of your intent handling code for further discussion?

— Ed Ford,  DTS Engineer

The solution was simpler than that. Apparently the intent is called on a background thread, so you have to set it asynchronous to be able to start the localisation. Another issue I found is that once a value is entered in the SiriKit interaction, the intent is started from scratch removing all saved values, that have therefore to be saved persistently, like for example the location. In any event that is a matter of trial and error. Now I'm busy at how to reserve keywords so that, for example, if someone says: "Puff a cloud with today is a nice day", my Virtual Tags app would be called and post a cloud with "Today is a nice day". At present I need to mention Virtual Tags to get attention from Siri.

CLLocationManagerDelegate not working on Siri Intents
 
 
Q