I have an app that relies heavily on AppIntents and Shortcuts and it seems like the latest iOS update broke those but I can't quite figure out what's the issue. The is that no matter what parameter I pick, when running the shortcut it always uses the defaultResult()
Here's an example AppEntity:
struct IntentBrokerAppEntity: AppEntity {
static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Intent Broker")
@Property(title: "Name")
var name: String?
@Property(title: "Ip")
var ip: String?
@Property(title: "Port")
var port: String?
@Property(title: "Username")
var username: String?
@Property(title: "Password")
var password: String?
@Property(title: "Tls")
var tls: Bool?
struct IntentBrokerAppEntityQuery: EntityQuery {
func entities(for identifiers: [IntentBrokerAppEntity.ID]) async throws -> [IntentBrokerAppEntity] {
return try await suggestedEntities().filter { identifiers.contains($0.id) }
}
func suggestedEntities() async throws -> [IntentBrokerAppEntity] {
let context = PersistenceController.shared.viewContext
let brokerService = BrokerService(context: context)
return brokerService.getFavorites().map { IntentBrokerAppEntity(broker: $0) }
}
func defaultResult() async -> IntentBrokerAppEntity? {
try? await suggestedEntities().first
}
}
static var defaultQuery = IntentBrokerAppEntityQuery()
var id: String // if your identifier is not a String, conform the entity to EntityIdentifierConvertible.
var displayString: String
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(title: "\(displayString)")
}
...
This used to work perfectly fine before 17.2, but now instead of choosing the entity the user picked it always falls back to defaultEntity()
.
In the console I get this warning
Failed to build EntityIdentifier. IntentBrokerAppEntity is not a registered AppEntity identifier
But I'm not sure if that's related. Does anyone have any ideas on what's going on here? Input much appreciated!