Contents

OnScreen

An expectation that specific app entities are onscreen.

Declaration

struct OnScreen

Overview

Use OnScreen to check that an entity is in the onscreen context Siri captures for a turn. OnScreen doesn’t show the entity itself, so before the evaluation runs, make sure your app is displaying it. For example, run an App Intent that opens the screen that shows the entity and then run the evaluation.

Unlike Finds, OnScreen matches by identity only and doesn’t use property constraints like .expect(title:). Write an empty entity definition to match any entity of that type, or call expectIdentifier(_:) to name a specific one.

The following example shows a turn that expects a specific quiz topic to be onscreen:

let quizExampleIntents = IntentDefinitions(bundleIdentifier: "com.example.QuizExample")
let quizTopicEntity = quizExampleIntents.entities["QuizTopicEntity"]

// The app is already showing the topic list.
UserTurn("Which quizzes are available in QuizExample?") {
    OnScreen {
        quizTopicEntity.expectIdentifier("Science")
    }
}

Topics

Creating an onscreen expectation

See Also

Expectations