I’m trying to receive a parameter in my app intent struct constructor to perform an action using this parameter value, but the perform method executes before my own init being executed. By the way, the WidgetConfigurationIntent protocol forces me to have an empty init, even I already have my own constructor, so I need to have two constructors, and the first one that is executed is the empty constructor and then the perform method. So, my ‘custom’ constructor is executed only after these two. That way, I always receiving nil when I going to use the value of myParameter in my perform intent method.
Does someone have any idea how to solve it?
My intent is somethig like this:
struct ConfigurationAppIntent: WidgetConfigurationIntent {
static var title: LocalizedStringResource = "Configuration"
static var description = IntentDescription("This is an example widget.")
var myParameter: MyCustomClass?
init(myParameter: MyCustomClass?) {
self.myParameter = myParameter
}
init() {}
func perform() async throws -> some IntentResult {
print("intent was executed")
return .result()
}
}