How to find the current focus status inside the app?
I implemented SetFocusFilterIntent for focus filter API. Is it possible to detect the current focus mode inside our main app?
Yes, it is possible to get the current configuration by accessing the static current
variable of your intent.
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
extension SetFocusFilterIntent {
public static var current: Self { get async throws }
}
If you need to initialise the appropriate handling of Focus Filters on startup of your app, you can use the following code in applicationDidFinishLaunching
or another event handler:
Task {
let filterIntent = try await SetFocusFilterIntent.current
_ = try await filterIntent.perform()
}