Get Text From AppEntity not work

https://medium.com/@giulio.caggegi/use-app-intents-with-ios-16-90a341ccbc94

I create a demo according this article, and add the App Intents in Shortcuts App , then add a Scripting "Get text from ***" , but the result is Empty, how could I modify the AppEntity or add which attribute, so the Scripting "Get text from ***" can get text from the App Intents?

Answered by DTS Engineer in 813337022

Thank you for the project. You should conform you entity type to Transferable Here's a simple version:

extension PokemonAppEntity: Transferable {
    static var transferRepresentation: some TransferRepresentation {
        ProxyRepresentation(exporting: \.name)
    }
}

You can make other choices for the representation implementation, so make sure to review the documentation for CoreTransferable to understand all of the implementation choices you could make.

One other tip here is that you can configure the type of the variables in the Shortcuts app. If you tap on AppEntityExtension within the Get text action, you'll get an editor that lets you use your Entity type, or some other system type, though you will still need the Transferable representation to a text type to make that work.

— Ed Ford,  DTS Engineer

Do you get the same results with just the relevant code in a small test project? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.

https://github.com/wyy912/App-Entity-Demo

The test project link is above. And the screenshot is the shortcut, I can get text from the shortcut or speak the text.

Accepted Answer

Thank you for the project. You should conform you entity type to Transferable Here's a simple version:

extension PokemonAppEntity: Transferable {
    static var transferRepresentation: some TransferRepresentation {
        ProxyRepresentation(exporting: \.name)
    }
}

You can make other choices for the representation implementation, so make sure to review the documentation for CoreTransferable to understand all of the implementation choices you could make.

One other tip here is that you can configure the type of the variables in the Shortcuts app. If you tap on AppEntityExtension within the Get text action, you'll get an editor that lets you use your Entity type, or some other system type, though you will still need the Transferable representation to a text type to make that work.

— Ed Ford,  DTS Engineer

Thank you! I learned a lot from your answer, and it solved my issue completely. I appreciate your time and expertise!

Get Text From AppEntity not work
 
 
Q