An object you use to access configuration information for controls and reload them.
ControlCenter provides information about user-configured controls, such as
their push information.
For additional information about offering controls that allow people to perform
app actions; -- for example, in Control Center on iPhone -- refer to <doc:Creating-controls-to-perform-actions-across-the-system>.
For more information about offering user-configured controls, refer to
<doc:Adding-refinements-and-configuration-to-controls#Add-configuration-to-a-control>.
### Access configured control information
To get a list of user-configured controls, use
<doc:ControlCenter/currentControls()>. This property provides an
array of <doc:ControlInfo> objects containing the following information:
struct ControlInfo {
public let kind: String
public func configurationIntent<Intent: ControlConfigurationIntent>(of intentType: Intent.Type = Intent.self) -> Intent?
public var pushInfo: ControlPushInfo?
}
The `kind` string matches the parameter you use when defining the control
type. If your control uses a <doc:AppIntentControlConfiguration>, the
``ControlInfo/configurationIntent(of:)`` function provides the custom intent
containing the user-customized values for each individual control. If your
control receives push notification updates, ``ControlInfo/pushInfo`` returns the push token you use to update it.
For more information about updating controls with WidgetKit push notifications,
refer to <doc:Updating-controls-locally-and-remotely>.
### Request a reload of your controls
Changes in your app’s state may affect a control's state. When this
happens, you can tell `ControlCenter` to reload the template for either a
specific kind of control or all controls. For example, someone might
press a button in your app that changes state shared by a control. The app
should reload that control for its display to reflect the new state.
You don't need to reload controls in response to push notifications. The
system reloads any controls that receive push notification updates on your
behalf.
If you only need to reload a certain kind of control, you can request a
reload for only that kind. For example, in response to the user toggling an
appliance on or off, you could request a reload for only the appliance
widgets:
ControlCenter.shared.reloadControls(ofKind: "com.myhome.appliancepower")
To request a reload for all of your controls:
ControlCenter.shared.reloadAllControls()
Members (4)
method · iOS 18.0+
reloadControls
TypeScript
reloadControls(kind: string): void
Swift declaration
func reloadControls(ofKind kind: String)
Reloads the templates for all controls of a particular kind.
- Parameter kind: A string that identifies the control and matches the
value you used to define the control.