appEntityIdentifier(_:)
Associates a SwiftUI view with an app entity to make its content discoverable by Apple Intelligence and Siri.
Declaration
nonisolated func appEntityIdentifier(_ identifier: EntityIdentifier?) -> some View
Parameters
- identifier:
The fully qualified identifier of the app entity instance you associate with the view.
Discussion
Use this modifier to make your app entity discoverable by Apple Intelligence and Siri and provide additional context to the system when the view appears onscreen. You can associate the view with one app entity. If you apply the modifier several times on one view, the system gives precedence to the innermost modifier and discards the other modifiers.
For example, this example associates entityA with the Rectangle() and entityB with BarView. The system ignores the modifier that associates entityC with the BarView:
struct FooView {
let entityA: EntityA
let entityB: EntityB
let entityC: EntityC
var body: some View {
BarView {
Rectangle()
.appEntityIdentifier(EntityIdentifier(for: EntityA.self, identifier: entityA.id))
}
.appEntityIdentifier(EntityIdentifier(for: EntityB.self, identifier: entityB.id))
.appEntityIdentifier(EntityIdentifier(for: EntityC.self, identifier: entityC.id))
}
}To remove the association, set appEntityIdentifier to nil.
For more information, refer to doc:Making-onscreen-content-available-to-siri-and-apple-intelligence and App Intents.