Upgrade to Pro — share decks privately, control downloads, hide ads and more …

今から理解するApp Intentエコシステム/WWDC24Recap

noppefoxwolf
July 01, 2024
1

今から理解するApp Intentエコシステム/WWDC24Recap

noppefoxwolf

July 01, 2024
Tweet

More Decks by noppefoxwolf

Transcript

  1. AppIntentΛ࡞ͬͯΈΔ import AppIntents struct OpenAppIntent: AppIntent { static let title:

    LocalizedStringResource = "ΞϓϦΛ։͘" func perform() async throws -> some IntentResult { // select tab .result() } static var openAppWhenRun: Bool = true @Parameter() var tabType: TabTypeAppEntity? } 14/37
  2. AppIntentΛ࡞ͬͯΈΔ struct TabTypeAppEntity: AppEntity { static var typeDisplayRepresentation = .init(name:

    "λϒͷछྨ") static var defaultQuery = TabTypeAppEntityQuery() let id: String let title: String var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(title)") } } 15/37
  3. ը໘ભҠͷ࣮૷ func perform() async throws -> some IntentResult { Router.shared.navigate(.home)

    .result() } var body: some View { TabView { ... } .onReceived(router) { value in selection = value } } 17/37
  4. ը໘ભҠͷ࣮૷ (iOS18) • ! URLRepresentableEntity • ! URLRepresentableEnum • !

    URLRepresentableIntent extension TabTypeAppEntity: URLRepresentableEntity { static var urlRepresentation: URLRepresentation { "https://example.com/tabs/\(.id)" } } طଘͷUniversal Linkͷ࣮૷Λ࢖͍·ΘͤΔ 18/37
  5. ! ɹTransferable AppEntity extension GreetingAppEntity: Transferable { static var transferRepresentation:

    some TransferRepresentation { DataRepresentation( exportedContentType: .png, exporting: { entity in entity.pngData() } ) } } 21/37
  6. struct OpenBookShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut(

    intent: PerformIntent(), phrases: [ "\(.applicationName)Λ։͍ͯ" ], shortTitle: "Open Example App", systemImageName: "apple.logo" ) } } 29/37
  7. AssistantSchema ! @AssistantIntent(schema: .system.search) // Add struct ExampleSearchIntent: ShowInAppSearchResultsIntent {

    static var searchScopes: [StringSearchScope] = [.general] @Parameter() var criteria: StringSearchCriteria func perform() async throws -> some IntentResult { let searchString = criteria.term print("Searching for \(searchString)") // ... return .result() } } 36/37