-
跟随编程:让你的 App 支持 Siri
跟随 Xcode 项目演示,深入探索如何让你的 App 支持 Siri。了解如何采用 App Schemas,让用户能够询问有关日历日程的问题,并执行日程安排等自然语言操作。探索相关最佳做法,以便将内容纳入“聚焦”语义索引,并为屏幕感知提供情境信息。
章节
- 0:00 - Introduction
- 1:43 - App Schemas and the plan
- 3:44 - Build the CalendarEntity
- 8:00 - Build the AttendeeEntity
- 10:30 - Build the EventEntity
- 14:34 - Open events with OpenIntent
- 15:30 - Onscreen awareness
- 17:18 - Create events with Siri
- 19:24 - Update events
- 21:30 - Custom snippet views
- 22:30 - Delete events
- 23:35 - Next steps
资源
- Integrating your calendar app with Apple Intelligence
- Donating your app’s data and actions to the system
- Donations and discovery
- Making app entities available in Spotlight
- Making actions and content discoverable by Apple Intelligence
- Providing contextual cues to Apple Intelligence and Siri
- Apple Intelligence and Siri AI
- Calendar
- App schema domains
相关视频
WWDC26
-
搜索此视频…
-
-
- 0:00 - Introduction
Justin Kang previews the goal: take an existing app and make it available to Siri. A picnic scenario shows Siri searching events, updating times with confirmation, texting attendees, and answering questions, all through conversation.
- 1:43 - App Schemas and the plan
Apps integrate with Apple Intelligence through App Intents, and App Schemas describe content and actions in terms Siri already understands, no training phrases or NLP. Schemas are organized into domains (here, the calendar domain). Introduces the CometCal sample app and the two goals: understand content, and perform actions.
- 3:44 - Build the CalendarEntity
Create a schematized @AppEntity from the calendar_calendar snippet, set the id to UUID, conform to IndexedEntity, wire a @Dependency and @MainActor query (EnumerableEntityQuery with allEntities()), set a display representation, and donate to Spotlight via indexAppEntities and deleteAppEntities.
- 8:00 - Build the AttendeeEntity
Built from calendar_attendee, but conforming to TransientAppEntity instead of IndexedEntity, attendees are accessed only through their event, so they need no identifier, query, or index. Introduces the IntentPerson type and two schematized @AppEnums (calendar_attendeeStatus, calendar_attendeeType).
- 10:30 - Build the EventEntity
The central IndexedEntity (from calendar_event), where the semantic index shines for title and note-content questions. Composes the CalendarEntity and [AttendeeEntity], handles recurrence (Calendar.RecurrenceRule), union values for location and alarms, and event status/span enums.
- 14:34 - Open events with OpenIntent
A small OpenEventIntent conforming to the system.open schema takes an EventEntity and tells the NavigationManager to navigate to it, so tapping an event in Spotlight or Siri opens straight to its detail view.
- 15:30 - Onscreen awareness
Two view modifiers connect the screen to entities: .appEntityIdentifier on the event list and .userActivity (with an EntityIdentifier) on the detail view, letting Siri resolve "this event" or "that third event" without naming the title.
- 17:18 - Create events with Siri
Build CreateEventIntent from calendar_createEvent: fill in parameter types, add a @MainActor @Dependency, and in perform() resolve the schema parameters (location union value, recurrence) into the data layer and return an EventEntity. Siri handles language, clarification, and confirmation.
- 19:24 - Update events
UpdateEventIntent (calendar_updateEvent) mostly mirrors create, but parameters are optional. The key subtlety: an IntentParameter's valueState distinguishes .set with a value (change it), .set with nil (explicitly clear it), and .unset (not part of the request).
- 21:30 - Custom snippet views
Replace Siri's default result card by adding ShowsSnippetView to the intent's return type and returning a custom SwiftUI EventSnippetView, bringing the app's visual personality (cosmic gradient, star icon) into Siri.
- 22:30 - Delete events
DeleteEventIntent is the simplest, just the event plus an optional span for recurring events, and Siri automatically handles confirmation and disambiguation before deleting.
- 23:35 - Next steps
Download the CometCal sample, browse the App Intents documentation for all schemas and domains, write tests with AppIntentsTesting, and watch "Explore advanced App Intents features for Siri and Apple Intelligence."