Creating a simple app intent
To demonstrate how to create an app intent, let’s imagine we have an amazing to-do list. Not just amazing, even mighty! So, we’ll call it MightyTasksList
.
Our MightyTasksList
app is so great that our users demand that they use it with Siri while they are driving. So, we decided to create an app intent.
To do that, we’ll open a new file and write the following code:
import AppIntents struct GetTasksIntent: AppIntent { static var title: LocalizedStringResource { "Get the number of opened tasks" } @MainActor func perform() async throws -> some ProvidesDialog { let tasks = TaskManager().tasks return .result( dialog: "Number of the opened tasks is \(tasks.count)") } }
This is it? Yes! Writing a simple app intent is...