IntentsUI extension not reached for INSearchForNot

2019-08-20 09:26发布

问题:

Implementing both custom and standard SiriKit intents and generally having good success. In principle, in the info.plist of both the Intents and IntentsUI extensions, you include the intent class supported, and the UI extension is run after the intent is successfully handled.

That is working for my custom intent (eg, MyAppCustomIntent) and for one of the standard intents (INSendMessageIntent). But for another intent I've implemented, INSearchForNotebookItemsIntent, the UI extension is never launched. The Intents extension is launched, the Siri interaction is processed accurately, and the default response for that intent is accurately provided by Siri. But the IntentsUI for that intent class simply is never attached by the debugger.

I'm using just one Intents extension and one IntentsUI extension, double-checked that all three Intents classes are in their respective IntentsSupported array for each extension, and added the class names by copy & paste to avoid misspellings.

What else might be preventing the UIExtension from launching for INSearchForNotebookItemsIntent beyond a failure response from the intent or improper setup of IntentsSupported in info.plist?

回答1:

Repurposed this from my comment above, which is an answer to the question though not technically the true solution since this seems like a bug in the API (that has lasted since its introduction).

I've found the custom UI will attach correctly if you supply more than one item (taskList, tasks, notes) on the successful response object, even empty objects, even though they are optional.

For example, when a single taskList is found in the search, I'll add a blank task object to the response.

response.tasks = [INTask(title: INSpeakableString(spokenPhrase: ""), status: .unknown, taskType: .unknown, spatialEventTrigger: nil, temporalEventTrigger: nil, createdDateComponents: nil, modifiedDateComponents: nil, identifier: "BugFixTask")]