supportedModes
The foreground and background modes the app intent supports.
Declaration
static var supportedModes: IntentModes { get }Mentioned in
Discussion
Use this property to specify whether your app needs to be in the foreground or background when running an app intent’s action. You can assign one or more values to this property:
Specify background to run the action entirely in the background.
Specify the immediate foreground mode to bring the app to the foreground before the action runs.
Specify the dynamic foreground mode to run the app in the background and optionally transition it to the foreground.
Specify the deferred foreground mode to run the app in the background, and then transition it to the foreground before the action completes.
Combine the foreground and background options to run the app in the foreground whenever possible, but allow it to run in the background as needed.
Combine the background and dynamic foreground mode to run the app in either the foreground or background, but to prefer the background.
Combine the background and deferred foreground mode to start the action in the background and transition to the foreground before the action finishes.
The following example shows how to specify the background and deferred foreground modes for this property:
struct SomeIntent: AppIntent {
static let supportedModes: IntentModes = [.background, .foreground(.deferred)]
...
}In your app intent’s perform() method, consult the information in the systemContext property of your app intent to determine whether your code is currently running in the foreground or background. The currentMode property of IntentSystemContext contains the current mode. You can also use the canContinueInForeground property to determine if a transition to the foreground is possible. For more information, see IntentModes.Current.