Hello,
I'm preparing my app Tameno for iOS 18, adding a couple of Control Center widgets.
One of them allows users to select their favorite interval. But in the context of my app, only seconds and minutes make sense as a unit value - I don't need milli-pseconds, nor hours.
Is there a way restrict these available options that come from a ControlConfigurationIntent?
@available(iOS 18.0, iOSApplicationExtension 18.0, *)
struct TamenoFavoriteIntervalControlWidgetSetupIntent : ControlConfigurationIntent {
static let title: LocalizedStringResource = "cw_FavoriteIntervalSetup"
static let isDiscoverable: Bool = false
@Parameter(title: "cw_IntervalParameter", defaultValue: 5.0, defaultUnit: .seconds, supportsNegativeNumbers: false) var interval: Measurement<UnitDuration>?
@MainActor
func perform() async throws -> some IntentResult {
.result()
}
}
I am able to restrict it just to seconds or minutes only (by adding unit: .seconds, or unit: .minutes to the @Parameter setup), but I'd really like to offer both.
Thank you,
- Matthias
Hi,
From our documentation of ControlConfigurationIntent
struct FocusOptionsProvider: DynamicOptionsProvider {
func results() async throws -> [Focus] {
FocusManager.shared.allFocuses
}
}
@Parameter(title: "Focus", optionsProvider: FocusOptionsProvider())
DynamicOptionsProvider allows you to customize this.
Rico
WWDR - DTS - Software Engineer