handleInApp response code not available in custom SiriKit intent

Hi,

I have created my own custom SiriKit Intent, and in the handler I am returning the response code of .continueInApp which opens my app in response. I've worked out that I want to open my app in the background, and .handleInApp seems to be the correct response code to do this.

However, .handleInApp is not an option in my intent's enum generated by Xcode. If I look at the auto-generated code, I see .continueInApp, and .success, etc, but no .handleInApp.

My Deployment Target is set to iOS 15.5 everywhere that I can find, so I really can't figure out why .handleInApp is not included in the auto-generated code. I've even tried creating a brand new workspace and project totally separate from my main one, and still creating a SiriKit Intent Definition does not generate code that includes .handleInApp.

Is there something I need to enable to make .handleInApp appear as an enum option?

Answered by DTS Engineer in 719602022

.handleInApp is only useful with specific intents. What do you expect to do with your app specifically in the background? Your intent extension is running as a background process, so you can perform work on behalf of your app in the background with this setup. You can also move your intent handling code to your main app entirely (eliminating the extension point) and handle the intent in the background that way, but before you do so, you should be clear on what work you expect to do in the background.

Accepted Answer

.handleInApp is only useful with specific intents. What do you expect to do with your app specifically in the background? Your intent extension is running as a background process, so you can perform work on behalf of your app in the background with this setup. You can also move your intent handling code to your main app entirely (eliminating the extension point) and handle the intent in the background that way, but before you do so, you should be clear on what work you expect to do in the background.

Thanks for your reply! I'm trying to enable a CLLocationManager with background tracking, amongst lots of other things (CoreData with iCloud etc), but it seems that when the location manager is started off from within the Intent, it doesn't then pick up the background location updates once the Intent has finished and exited. But the same code works when being used from the main app itself. It currently works if I make the Intent respond with a .continueInApp, because the app then starts up and it enables the location manager there and it does the background tracking. But I don't want it to bring the app to the foreground.

To give some background about the overall task I'm trying to achieve, I want to... be able to plug my iPhone into my CarPlay unit and it fire of a shortcut (which is possible with Shortcuts app) that then tells my own app to start tracking the route (i.e. locations). So I have an Intent in my app which is "start route recording" which stores some data (CoreData) to tell my app that a route is being recorded, and then a CLLocationManager is started up to accept background updates. It all works, just not from my Intent. If I enable the CLLocationManager from the Intent, it seems happy enough (no obvious errors) but it just doesn't seem to fire off the background updates and store the tracking data.

So how do I move my Intent code to my main app and have it fired off from the Shortcuts app?

I found this WWDC video which explains exactly what I needed to do to make my Intent an in-app Intent, and so far it seems to be behaving perfectly as I need...

https://developer.apple.com/videos/play/wwdc2020/10073/

handleInApp response code not available in custom SiriKit intent
 
 
Q