[18.2b2] How do I test an OpenIntent?

So, I've declared an AppIntent that indicates my app can "Open files" that conform to UTType.Image.

I've got a @AssistantEntity(schema: .files.file) and a @AssistantIntent(schema: .files.openFile) declared.

So I navigate to the files app, quicklook an image, and open type-to-siri.

I tell siri "open this in <app name>" and all it does is act like "open <app name>". No breakpoint is hit in my intent's perform method.

Am I doing something wrong? How can I test these cross-app behaviors?

Are they... not actually possible? Does an "OpenIntent" only work on my app's own URLs and not on file URLs from other apps?

I like to use the Shortcuts app for testing. If you create a file reference in a shortcut, and then pass that file to your new open intent as the next step in a shortcut, what happens? If that much works, then you're on the right path. If that doesn't work, review the documentation article on the files domain to make sure you haven't forgotten something in your implementation.

— Ed Ford,  DTS Engineer

@DTS Engineer

It looks like the system, when invoking an OpenIntent, knows the input target of the intent, and knows the "ID" of the "target". In my case it's the special FileEntityIdentifier

Using the code on the documentation will not work because func entities(for identifiers: [FilesEntity.ID]) async throws -> [FilesEntity] { [] } is not converting the system provided FileEntityIdentifier to a "FilesEntity", so there's no target to invoke the OpenIntent with.

Here's the fix for that:

        func entities(for identifiers: [FilesEntity.ID]) async throws -> [FilesEntity] {
            identifiers.map {
                FilesEntity(
                    id: $0,
                    creationDate: nil,
                    fileModificationDate: nil
                )
            }
        }

I've resolved this and ALSO provided the OpenIntent using the "AppShortcutsProvider". Otherwise it does not appear in shortcuts.

The good news: When invoked from the provided shortcuts area it works!

I am not able to add it to a custom-shortcut as an action, though, I can only invoke it directly from the provided shortcuts card.

Questions

  • Now that I know the OpenIntent works, how can I invoke it with Siri? It seems any phase with "open" in it still just opens my app.

  • Does the OS provide a "file" to Siri anywhere? How can I know this? I've tried a quick looked file in the Files app and phrases like "Open this in <App name>".

[18.2b2] How do I test an OpenIntent?
 
 
Q