I added Siri to my project and used IntentHandler to handle Siri's intents. I then added Widget to my project so needed to handle its intents also.
I extended my IntentHandler's handler function to handle also Widget intents and it works, however I don't understand where in my xcode project the Widget is configured to use the same IntentHandler, and I even see that this file is not included in Widget target so don't understand how it works.
Didn't find anywhere in documentation an explanation on how to configure which intent handler will handle intents, and specifically if it's possible to define multiple IntentHandler instances, one to handle Siri's intent and another one to handle Widget's intents, and if yes how to do so.
I asked this question also in Apple Developer Forums but didn't get any response.
where in my xcode project the Widget is configured to use the same IntentHandler
In the Widget extension you only specify which Intent to use (by implementing IntentConfiguration
, IntentTimelineProvider
etc).
In the IntentHandler extension you specify which Intents to support.
It's all connected by the parent app and the type of Intent. IntentHandler
doesn't know anything about Widget
(and vice versa).
how to configure which intent handler will handle intents
It can be configured in the Info.plist
file of the IntentHandler
extension. Specifically in the IntentsSupported
section:
if it's possible to define multiple IntentHandler instances, one to handle Siri's intent and another one to handle Widget's intents
Yes, you can create two IntentHandler
extensions and select which Intents to support in the IntentsSupported
section (as in the image above).
Here is a GitHub repository with different Widget examples including the Dynamic Intent Widget.