Contents

IntentModes.Current

The current runtime behavior of an app intent.

Declaration

struct Current

Overview

This type provides information about an app intent’s current runtime behavior. When an intent runs, its systemContext property contains additional contextual information you can use to make decisions. Specifically, the currentMode property tells you whether the intent is currently running in the foreground or background.

Don’t create instances of this type yourself. Instead, compare the value in the currentMode property to the static values this type defines. You can also check the canContinueInForeground property to determine if a background intent can switch to the foreground. The following code shows how to use this type from an app intent’s perform() method:

if systemContext.currentMode == .background {
   if systemContext.currentMode.canContinueInForeground {
      try await continueInForeground()
   } else {
      // The current conditions don't allow the app intent to continue in the foreground,
      // so it needs to continue in the background.
   }
}

Topics

Instance Properties

Type Properties