Posts

Post not yet marked as solved
0 Replies
75 Views
I'm using the TrailsSampleApp (in the AppIntentsSampleApp project which is provided by Apple. According to the code, if you use the "Get conditions with TrailsSampleApp" and provide a trail that is NOT in the suggested entities, it should pass control to the following TrailEntityQuery extension. /// An EntityStringQuery extends the capability of an EntityQuery by allowing people to search for an entity with a string. extension TrailEntityQuery: EntityStringQuery { /** To see this method, configure the Get Trail Info intent in the Shortcuts app. A list displays the suggested entities. If you search for an entity not in the suggested entities list, the system passes the search string to this method. - Tag: string_query */ func entities(matching string: String) async throws -> [TrailEntity] { Logger.entityQueryLogging.debug("[TrailEntityQuery] String query for term \(string)") return trailManager.trails { trail in trail.name.localizedCaseInsensitiveContains(string) }.map { TrailEntity(trail: $0) } } } It says if you configure the Get Trail Info section in the Shortcuts App, control will be passed to this entities() function. However, it doesn't say how to configure it. Any suggestions or help?
Posted
by bobku.
Last updated
.
Post not yet marked as solved
0 Replies
104 Views
I'm adding AppIntents to my existing "ShopList" app and I'm having two problems that I think are related. I can't get shortcuts (or Siri) to work when I pass a parameter to an intent. It works if I don't pass a parameter though. My StoreEntityQuery.suggestedEntities function is not being called during initialization. I have an AppIntentsShortcutProvider defined as follows. class ShopListShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut(intent: FindStore(), phrases: [ "Find \(\.$store) store in \(.applicationName)" ], shortTitle: "Find Store", systemImageName: "cart") } } Details below. I would appreciate any suggestions on what I'm missing or doing wrong. In my AppDelegate "didFinishLaunchingWithOptions" function, I call ShopListShortcuts.updateShortcutParameters. The FindStore struct is defined as follows. struct FindStore: AppIntent { static var title: LocalizedStringResource = "Find Store" static var description = IntentDescription("Finds a store.") static var openAppWhenRun: Bool = false @Parameter(title: "Store", description: "The store.") var store: StoreEntity @MainActor func perform() async throws -> some IntentResult { print("performing intent with \(store.id) and \(store.name)") return .result() } } The StoreEntity is defined as follows. struct StoreEntity: AppEntity { ... static var defaultQuery = StoreEntityQuery() var id: Store.ID @Property(title: "Store Name") var name: String ... } And finally the StoreEntityQuery is defined as follows. struct StoreEntityQuery: EntityQuery { func entities(for identifiers: [StoreEntity.ID]) async throws -> [StoreEntity] { print("entities call") return ... } func suggestedEntities(for identifiers: [StoreEntity.ID]) async throws -> [StoreEntity] { print("suggested entities call") return ... } }
Posted
by bobku.
Last updated
.
Post not yet marked as solved
0 Replies
236 Views
I have a shopping list app that shares a list of Product records between users. The app on my phone shared its private database with another user account (running on a simulator) which accepted it. Both devices can see changes from the other if the device does a full refresh from iCloud. Now I want to have the app on the devices be notified when the other changes/adds/deletes a Product record. I did the following to get push notifications to work (but haven't been successful yet) I have enabled background fetch and remote notifications in my app capabilities. The app registers for remote notifications with UIApplication.shared.registerForRemoteNotifications() and receives the didRegisterForRemoteNotificationsWithDeviceToken callback. The app sets a subscription with CKModifySubscriptionsOperation for the "Product" recordType. I set the QoS to .utility on the appropriate private or shared database. However, when I add a Product record on my record, the didReceiveRemoteNotification callback doesn't execute. What am I missing?
Posted
by bobku.
Last updated
.