I've found the issue. The FocusFilterIntent was only called once, since I've had Parameters inside that were not optional. It seems like it isn't able to infer the parameters that are non optional when deactivating the Focus Mode.
So simply marking the Parameters as optional solves this problem.
struct FocusFilterIntent: SetFocusFilterIntent {
static let title: LocalizedStringResource = "Some Title"
static let description: LocalizedStringResource = """
Some Description
"""
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(title: "App", subtitle: "Subtitle")
}
@Parameter(title: "Param1")
var param1: Param1? // turned to optional
func perform() async throws -> some IntentResult {
Logger.focus.info("FocusFilterIntent called")
if let param1 = param1 {
// do something, filter is activated
} else {
// filter is deactivated
}
return .result()
}
Topic:
App & System Services
SubTopic:
General
Tags: