Dive into App Intents

RSS for tag

Discuss the WWDC22 Session Dive into App Intents

Posts under wwdc2022-10032 tag

37 Posts

Post

Replies

Boosts

Views

Activity

AppIntents EntityPropertyQuery, how does "Filter Entity where" work?
When you correctly implement EntityPropertyQuery on an AppEntity, Shortcuts will expose a "Find Entity" action that calls into entities(matching:mode:sortedBy:limit:). This is demoed in the "Dive into App Intents" session and works as expected. However, with this action, you can change the "All Entity" input to a list variable which changes the action text from "Find All Entity" to "Filter Entity where" still giving you the same filter, sort and limit options. This appears to work as expected too. But, what's unexpected is that this filter action does not appear to call any method on my AppEntity code. It doesn't call entities(matching:mode:sortedBy:limit:). One would think there would need to be a filter(entities:matching:mode:sortedBy:limit:) to implement this functionality. But Shortcut just seems to do it all on it's own. I'm mostly wondering, how is this even working? Here's some example code: import AppIntents let books = [ BookEntity(id: 0, title: "A Family Affair"), BookEntity(id: 1, title: "Atlas of the Heart"), BookEntity(id: 2, title: "Atomic Habits"), BookEntity(id: 3, title: "Memphis"), BookEntity(id: 4, title: "Run Rose Run"), BookEntity(id: 5, title: "The Maid"), BookEntity(id: 6, title: "The Match"), BookEntity(id: 7, title: "Where the Crawdads Sing"), ] struct BookEntity: AppEntity, Identifiable { static var typeDisplayRepresentation: TypeDisplayRepresentation = "Book" var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(title)") } static var defaultQuery = BookQuery() var id: Int @Property(title: "Title") var title: String init(id: Int, title: String) { self.id = id self.title = title } } struct BookQuery: EntityQuery { func entities(for identifiers: [Int]) async throws -> [BookEntity] { return identifiers.map { id in books[id] } } } extension BookQuery: EntityPropertyQuery { static var properties = QueryProperties { Property(\BookEntity.$title) { EqualToComparator { str in { book in book.title == str } } ContainsComparator { str in { book in book.title.contains(str) } } } } static var sortingOptions = SortingOptions { SortableBy(\BookEntity.$title) } func entities( matching comparators: [(BookEntity) -> Bool], mode: ComparatorMode, sortedBy: [Sort<BookEntity>], limit: Int? ) async throws -> [BookEntity] { books.filter { book in comparators.allSatisfy { comparator in comparator(book) } } } } The example Shortcut first invokes entities(matching:mode:sortedBy:limit:) with comparators=[], sortedBy=[], limit=nil to fetch all Book entities. Next the filter step correctly applies the title contains filter but never calls entities(matching:mode:sortedBy:limit:) or even the body of the ContainsComparator. But the output is correctly filtered.
1
0
1.7k
Jul ’25
Using Maps in App Intents
I want to use MapKit with App Intents, but the map does not show up.(See attached image) Can anyone help me solve this? import SwiftUI import MapKit struct ContentView: View {   @State private var region = MKCoordinateRegion(     center: CLLocationCoordinate2D(latitude: 37.334_900,                     longitude: -122.009_020),     latitudinalMeters: 750,     longitudinalMeters: 750   )       var body: some View {     VStack {       Map(coordinateRegion: $region).frame(width:300, height:300)         .disabled(true)     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } import AppIntents import SwiftUI import MapKit struct test20220727bAppIntentsExtension: AppIntent {   static var title: LocalizedStringResource = "test20220727bAppIntentsExtension"       func perform() async throws -> some IntentResult {     return .result(value: "aaa", view: ContentView())   } } struct testShortcuts:AppShortcutsProvider{   @available(iOS 16.0, *)   static var appShortcuts: [AppShortcut]{     AppShortcut(       intent: test20220727bAppIntentsExtension(),       phrases: ["test20220727bAppIntentsExtension" ]     )   } }
2
0
1.3k
Mar ’25
IntentDonationManager not donating Shortcuts
if #available(iOS 16.0, *) {       print("donated")       let intent = BasicIntent()       IntentDonationManager.shared.donate(intent: intent)    } Trying to test if donations work with the new App Intents framework. Donating the shortcut once a user taps a button. The shortcut is not appearing on the lock screen. Everything else is working as expected. The Shortcut is appearing in the Shortcuts App and is working via Siri. In developer settings I have Display Recent Shortcuts -> On Display Donations on Lock Screen -> On Allow Any domain -> On Allow Unverified sources -> On Running iOS 16.2, iPhone 11.
8
2
2.7k
Mar ’25
AppIntent with long-running perform()
I'm using the AppIntents framework introduced in iOS 16. My goal is to create an AppIntent that performs a long-running task but does open my app when run. When I run the Intent from the Shortcuts app, I see an error message that says the shortcut "was interrupted because it didn't finish executing in time." Is there a way to signal progress to the user of a long-running AppIntent or get more time from the system prior to the AppIntent being cancelled?
3
1
2.3k
Jan ’25
App Intents with OpensIntent does not work correctly
We are developing an app for iOS 16 using App Intents and Siri. We have been testing the behavior of opening another App Intent by passing the opensIntent argument to the result function in the App Intent with iOS 16.4 devices. As a result, we found that the dialog text specified in the result argument of the Intent to which it transitions is not displayed and therefore does not work. And also found that when invoked from Siri, the Intent passed to the opensIntent argument is invoked "twice". Are these behaviors bugs? Any ideas? The following is a sample code and logs. import AppIntents struct PrimaryIntent: AppIntent { static var title: LocalizedStringResource = "Primary" func perform() async throws -> some OpensIntent { print("\(String(describing: Self.self)).\(#function): invoked") return .result(opensIntent: SecondaryIntent()) } } struct SecondaryIntent: AppIntent { static var title: LocalizedStringResource = "Secondary" func perform() async throws -> some ProvidesDialog { print("\(String(describing: Self.self)).\(#function): invoked") return .result(dialog: .init(stringLiteral: "test")) } } struct ShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut(intent: PrimaryIntent(), phrases: ["\(.applicationName)"]) } } logs from Shortcut App PrimaryIntent.perform(): invoked SecondaryIntent.perform(): invoked # is not displayed dialog... logs from Siri PrimaryIntent.perform(): invoked SecondaryIntent.perform(): invoked SecondaryIntent.perform(): invoked # is not displayed dialog... # SecondaryIntent invoked twice...
3
1
2.2k
Aug ’23
Creating a Continuous Conversation with Siri Using App Intents
Hello, I am working on an app that uses App Intents to enable users to interact with Siri. Here is the code I'm using: struct SiriPassMeLuna: AppIntent { static var title: LocalizedStringResource = "Pass me Luna" static var description = IntentDescription("Lets you query Luna and receive a response.") @Parameter(title: "Phrase") var phrase: String? func perform() async throws -> some IntentResult { guard let providedPhrase = phrase else { throw $phrase.needsValueError("What do you need help with?") } let request = Request() let reply = request.sendRequest(transcription: providedPhrase) return .result(dialog: "\(reply)") } } struct SiriAppShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: SiriPassMeLuna(), phrases: ["Pass me \(.applicationName)"] ) } } My goal is to create a continuous conversation with Siri, where the user can speak to the intent, and then the intent keeps listening and replying without the user having to invoke Siri and the intent each time. Is there a way to achieve this behavior, so that the conversation with Siri is more seamless, and the user doesn't have to repeatedly say "Hey Siri" followed by the intent name? Any guidance or suggestions would be greatly appreciated. Thank you!
1
0
2.1k
Jun ’23
Disappearing AppIntents
My AppIntents were showing in the Shortcuts app. Now they don't. If I try to create a shortcut my app doesn't show in the list of apps that have shortcuts. I have no compile or linking errors. I'm using Xcode 14.1. My app is UIKit based though it has lots of SwiftUI. Any ideas on how to resolve this would be greatly appreciated.
3
0
1.4k
Jun ’23
Adding a Value Prompt before invoking the sendQuestionToMe function
I'm currently working on an app that utilizes AppIntents. I have a specific requirement where I want the user to be able to ask a question using a Value Prompt before the sendQuestionToMe function is invoked. Here's a snippet of my code: // Imports and struct definitions... struct QuestionForAll: AppIntent { // Intent properties... func perform() async throws -> some IntentResult & ProvidesDialog { let entities = try await QuestionAppEntityQuery().suggestedEntities() let questions = entities.map { $0.name } guard let question = question else { throw NSError(domain: "", code: -1, userInfo: [NSLocalizedDescriptionKey: "No question provided"]) } let answer = try await sendQuestionToMe(question) print(answer) // Return the response as an IntentResult return .result( dialog: IntentDialog(stringLiteral: answer) ) } } I would like to add a Value Prompt to the perform() function so that the user can input their question before the sendQuestionToMe function is called. Could someone please guide me on how to implement this? Any help would be greatly appreciated. Thank you in advance!
1
0
955
May ’23
App Intents string type parameter in Shortcut app can't change keyboard
Here is my code : struct NoteIntent: AppIntent { // 3 static var title: LocalizedStringResource = "Write memo" static var openAppWhenRun: Bool = false // 4 @Parameter(title: "Input") var input: String? // 5 @MainActor func perform() async throws -> some ProvidesDialog & IntentResult { guard let providedPhrase = input else { InputViewModel.shared.firstSiriNote = nil throw $input.needsValueError( "Write something") } return .result(dialog: IntentDialog("👏🏻Success!")) } static var parameterSummary: some ParameterSummary { Summary("\(\.$input)") } } My problem is that in Shortcut app input sting parameter only call default keboard,i can't switch third part keyboard or other launguge type
3
0
1.5k
May ’23
AppIntent Parameter type Duration
Hi, I have developed an iOs app (16+) with SwiftUI. Now I am adding the ability to use voice commands with Siri by creating App Intents. I would like to give users the ability to be able to say, "Siri records 2 hours and 30 for client Mark." For the time part I was thinking of using the @Parameter with data type "Duration" but I get error back and maybe it is not the right type since it accepts seconds as input. What do you recommend? Thanks import Foundation import AppIntents import UIKit struct AddExpense: AppIntent {          static var title: LocalizedStringResource = "Record"          @Parameter(title: "Customer")     var dossier: String          @Parameter(title: "Time")     var tempo: Duration                   func perform() async throws -> some IntentResult & ProvidesDialog  {         //await addExpense()         let dialog = IntentDialog("Ok!")         return .result(dialog: dialog)     } } Error: Generic class 'IntentParameter' requires that 'Duration' conform to '_IntentValue' Warning: Stored property '_tempo' of 'Sendable'-conforming struct 'AddExpense' has non-sendable type '<>' Documentation [https://developer.apple.com/documentation/appintents/providing-your-app-s-capabilities-to-system-services]
1
0
1.8k
May ’23
App Intents don't show on device, while they do in the simulator
Hello. I want to provide my users with some useful shortcuts and chose AppIntents to do so. I watched the relevant WWDC talks, read the documentation and I set up a few simple intents, adhering to AppIntent. I also created a AppShortcutsProvider to offer the most useful of my intents on installation. I did use \(.applicationName) within my phrases. Trying it out on the simulator, it works as intended (Ventura 13.3, Xcode 14.3, iOS 16.4). Wonderful! Now, building the same code for my hardware device (iPhone SE 3rd Gen, iOS 16.4) and trying it out on there, nothing shows up - neither the intents I want to add on install, nor the ones the user would have to select manually. I really have no idea why... On a side note: My app does have a Watch counterpart and I'd like to do the same there, but with intents specific to the Watch app. They don't even show up in the simulator, though. Any ideas what could've went wrong here? I'd appreciate it. Thanks!
3
0
3.3k
Apr ’23
AppShortcutsProvider pharses not recognizable by Siri
We have implemented AppIntents in iOS16 and the shortcuts are working fine when manually added in shortcuts app. But the shortcuts created programaticaly using AppShortcutsProvider with AppShortcutsPhrases are not at all recognized by Siri. The AppIntents core feature is zero setup shortcuts, but it is not working as expected. Please suggest any fix for this. Sample Code: struct NotesShortcutProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { let shortcut = AppShortcut(intent: ShowTodayTasks(), phrases: ["Show today tasks","show my tasks today"]) return [shortcut] } } Tried with applicationName as well but no luck.
4
2
2.8k
Apr ’23
Parent parameters
Is it possible to filter a parameter based on a previous parameter value submitted by the user? Something similar to the parent parameter option available in the intent definition file. What I'm trying is to filter the options in DynamicOptionsProvider based on previous answers submitted by the user.
1
1
1.2k
Mar ’23
AppEntity Display Issue on Siri Shortcut with AppIntents
My Shortcut is built using the new AppIntents framework for Siri. The problem is subtitles and images on my AppEntity appear when running the shortcut in the shortcuts app, but they do not show up when running on Siri. This is a client requirement and I can't figure out how to fix this. I am using the proper DisplayRepresentation. See images below     .init(title: "\(displayString)", subtitle: "\(fullAddress)",image: imageUrl.isEmpty ? DisplayRepresentation.Image(systemName: "fork.knife.circle.fill") : DisplayRepresentation.Image(url: URL(string: imageUrl )! )) Here's how it appears in Shortcuts: Here's how it appears on SIri:
0
0
1.4k
Feb ’23
Can I Combine System Actions with Custom Intents to Create a Shortcut in iOS App Development?
Is it possible to create a custom app shortcut using system actions and custom intents in iOS development? For instance, can my app generate a shortcut that combines dictation text, note creation, and speech output using Siri speakers? If not, is there a way to access dictation text or Siri speakers from within my custom app intent?
0
0
829
Feb ’23
Difference between Custom Intents and App Intents
Hi everyone. Can someone explain the difference between custom intents and app intents, and provide documentation for the type of intent needed to create a shortcut from an installed app with the same functionality as the manual "repeat text" shortcut created on my phone which listens for speech and repeats it using Siri speakers?
0
0
1k
Feb ’23
LocalizedStringResource with Formatter
I am trying to use DateComponentsFormatter() with my AppIntent, but I can not find a way to localize the formatter string with the same language that LocalizedStringResource use... Example (My App: Arabic, Device: English, Siri: English) let formatter = DateComponentsFormatter()     formatter.unitsStyle = .full     formatter.maximumUnitCount = 2     formatter.allowedUnits = [.hour, .minute]     formatter.includesTimeRemainingPhrase = true let relativeDate = formatter.string(from: .now, to: nextEvent.date) ?? ""      return .result(             value: value,             dialog: "intent_current_event\(relativeDate)"           ) The result is: Next event متبقي 4 ساعات و 5 دقائق The relativeDate is in Arabic (App Language) and the "intent_current_event%@" localized in English (Siri Language) Can anyone please help me to use the Formatter and get it to localized the same local as LocalizedStringResource.
3
0
2.0k
Dec ’22
App Intent not Discoverable by Siri
I'm implementing the iOS 16 AppIntents framework and it works fine except when I try to trigger it with Siri, which just pulls up results from the web. Here's a very simple version I made on an empty project. import Foundation import AppIntents @available(iOS 16.0, *) struct ShowMeBooks: AppIntent {     static var openAppWhenRun: Bool = false     static var title: LocalizedStringResource = "Show me my books"          func perform() async throws -> some IntentPerformResult {         let x = 1 + 1         return .finished(dialog: "Here are your books")     } } @available(iOS 16.0, *) struct SouthwestShortcuts: AppShortcutsProvider {     static var appShortcuts: [AppShortcut] {         AppShortcut(             intent: ShowMeBooks(),             phrases: ["Show me my books on \(.applicationName)"]         )     } }
9
1
5.5k
Dec ’22
AppIntents EntityPropertyQuery, how does "Filter Entity where" work?
When you correctly implement EntityPropertyQuery on an AppEntity, Shortcuts will expose a "Find Entity" action that calls into entities(matching:mode:sortedBy:limit:). This is demoed in the "Dive into App Intents" session and works as expected. However, with this action, you can change the "All Entity" input to a list variable which changes the action text from "Find All Entity" to "Filter Entity where" still giving you the same filter, sort and limit options. This appears to work as expected too. But, what's unexpected is that this filter action does not appear to call any method on my AppEntity code. It doesn't call entities(matching:mode:sortedBy:limit:). One would think there would need to be a filter(entities:matching:mode:sortedBy:limit:) to implement this functionality. But Shortcut just seems to do it all on it's own. I'm mostly wondering, how is this even working? Here's some example code: import AppIntents let books = [ BookEntity(id: 0, title: "A Family Affair"), BookEntity(id: 1, title: "Atlas of the Heart"), BookEntity(id: 2, title: "Atomic Habits"), BookEntity(id: 3, title: "Memphis"), BookEntity(id: 4, title: "Run Rose Run"), BookEntity(id: 5, title: "The Maid"), BookEntity(id: 6, title: "The Match"), BookEntity(id: 7, title: "Where the Crawdads Sing"), ] struct BookEntity: AppEntity, Identifiable { static var typeDisplayRepresentation: TypeDisplayRepresentation = "Book" var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(title)") } static var defaultQuery = BookQuery() var id: Int @Property(title: "Title") var title: String init(id: Int, title: String) { self.id = id self.title = title } } struct BookQuery: EntityQuery { func entities(for identifiers: [Int]) async throws -> [BookEntity] { return identifiers.map { id in books[id] } } } extension BookQuery: EntityPropertyQuery { static var properties = QueryProperties { Property(\BookEntity.$title) { EqualToComparator { str in { book in book.title == str } } ContainsComparator { str in { book in book.title.contains(str) } } } } static var sortingOptions = SortingOptions { SortableBy(\BookEntity.$title) } func entities( matching comparators: [(BookEntity) -> Bool], mode: ComparatorMode, sortedBy: [Sort<BookEntity>], limit: Int? ) async throws -> [BookEntity] { books.filter { book in comparators.allSatisfy { comparator in comparator(book) } } } } The example Shortcut first invokes entities(matching:mode:sortedBy:limit:) with comparators=[], sortedBy=[], limit=nil to fetch all Book entities. Next the filter step correctly applies the title contains filter but never calls entities(matching:mode:sortedBy:limit:) or even the body of the ContainsComparator. But the output is correctly filtered.
Replies
1
Boosts
0
Views
1.7k
Activity
Jul ’25
Using Maps in App Intents
I want to use MapKit with App Intents, but the map does not show up.(See attached image) Can anyone help me solve this? import SwiftUI import MapKit struct ContentView: View {   @State private var region = MKCoordinateRegion(     center: CLLocationCoordinate2D(latitude: 37.334_900,                     longitude: -122.009_020),     latitudinalMeters: 750,     longitudinalMeters: 750   )       var body: some View {     VStack {       Map(coordinateRegion: $region).frame(width:300, height:300)         .disabled(true)     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } import AppIntents import SwiftUI import MapKit struct test20220727bAppIntentsExtension: AppIntent {   static var title: LocalizedStringResource = "test20220727bAppIntentsExtension"       func perform() async throws -> some IntentResult {     return .result(value: "aaa", view: ContentView())   } } struct testShortcuts:AppShortcutsProvider{   @available(iOS 16.0, *)   static var appShortcuts: [AppShortcut]{     AppShortcut(       intent: test20220727bAppIntentsExtension(),       phrases: ["test20220727bAppIntentsExtension" ]     )   } }
Replies
2
Boosts
0
Views
1.3k
Activity
Mar ’25
IntentDonationManager not donating Shortcuts
if #available(iOS 16.0, *) {       print("donated")       let intent = BasicIntent()       IntentDonationManager.shared.donate(intent: intent)    } Trying to test if donations work with the new App Intents framework. Donating the shortcut once a user taps a button. The shortcut is not appearing on the lock screen. Everything else is working as expected. The Shortcut is appearing in the Shortcuts App and is working via Siri. In developer settings I have Display Recent Shortcuts -> On Display Donations on Lock Screen -> On Allow Any domain -> On Allow Unverified sources -> On Running iOS 16.2, iPhone 11.
Replies
8
Boosts
2
Views
2.7k
Activity
Mar ’25
AppIntent with long-running perform()
I'm using the AppIntents framework introduced in iOS 16. My goal is to create an AppIntent that performs a long-running task but does open my app when run. When I run the Intent from the Shortcuts app, I see an error message that says the shortcut "was interrupted because it didn't finish executing in time." Is there a way to signal progress to the user of a long-running AppIntent or get more time from the system prior to the AppIntent being cancelled?
Replies
3
Boosts
1
Views
2.3k
Activity
Jan ’25
AppIntents with UIKit
My app is mostly implemented in UIKit. Will AppIntents work with UIKit? If so, which (scene or app) delegate method gets called to start the intent?
Replies
1
Boosts
0
Views
1.5k
Activity
Sep ’24
App Intents with OpensIntent does not work correctly
We are developing an app for iOS 16 using App Intents and Siri. We have been testing the behavior of opening another App Intent by passing the opensIntent argument to the result function in the App Intent with iOS 16.4 devices. As a result, we found that the dialog text specified in the result argument of the Intent to which it transitions is not displayed and therefore does not work. And also found that when invoked from Siri, the Intent passed to the opensIntent argument is invoked "twice". Are these behaviors bugs? Any ideas? The following is a sample code and logs. import AppIntents struct PrimaryIntent: AppIntent { static var title: LocalizedStringResource = "Primary" func perform() async throws -> some OpensIntent { print("\(String(describing: Self.self)).\(#function): invoked") return .result(opensIntent: SecondaryIntent()) } } struct SecondaryIntent: AppIntent { static var title: LocalizedStringResource = "Secondary" func perform() async throws -> some ProvidesDialog { print("\(String(describing: Self.self)).\(#function): invoked") return .result(dialog: .init(stringLiteral: "test")) } } struct ShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut(intent: PrimaryIntent(), phrases: ["\(.applicationName)"]) } } logs from Shortcut App PrimaryIntent.perform(): invoked SecondaryIntent.perform(): invoked # is not displayed dialog... logs from Siri PrimaryIntent.perform(): invoked SecondaryIntent.perform(): invoked SecondaryIntent.perform(): invoked # is not displayed dialog... # SecondaryIntent invoked twice...
Replies
3
Boosts
1
Views
2.2k
Activity
Aug ’23
Creating a Continuous Conversation with Siri Using App Intents
Hello, I am working on an app that uses App Intents to enable users to interact with Siri. Here is the code I'm using: struct SiriPassMeLuna: AppIntent { static var title: LocalizedStringResource = "Pass me Luna" static var description = IntentDescription("Lets you query Luna and receive a response.") @Parameter(title: "Phrase") var phrase: String? func perform() async throws -> some IntentResult { guard let providedPhrase = phrase else { throw $phrase.needsValueError("What do you need help with?") } let request = Request() let reply = request.sendRequest(transcription: providedPhrase) return .result(dialog: "\(reply)") } } struct SiriAppShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: SiriPassMeLuna(), phrases: ["Pass me \(.applicationName)"] ) } } My goal is to create a continuous conversation with Siri, where the user can speak to the intent, and then the intent keeps listening and replying without the user having to invoke Siri and the intent each time. Is there a way to achieve this behavior, so that the conversation with Siri is more seamless, and the user doesn't have to repeatedly say "Hey Siri" followed by the intent name? Any guidance or suggestions would be greatly appreciated. Thank you!
Replies
1
Boosts
0
Views
2.1k
Activity
Jun ’23
Disappearing AppIntents
My AppIntents were showing in the Shortcuts app. Now they don't. If I try to create a shortcut my app doesn't show in the list of apps that have shortcuts. I have no compile or linking errors. I'm using Xcode 14.1. My app is UIKit based though it has lots of SwiftUI. Any ideas on how to resolve this would be greatly appreciated.
Replies
3
Boosts
0
Views
1.4k
Activity
Jun ’23
Adding a Value Prompt before invoking the sendQuestionToMe function
I'm currently working on an app that utilizes AppIntents. I have a specific requirement where I want the user to be able to ask a question using a Value Prompt before the sendQuestionToMe function is invoked. Here's a snippet of my code: // Imports and struct definitions... struct QuestionForAll: AppIntent { // Intent properties... func perform() async throws -> some IntentResult & ProvidesDialog { let entities = try await QuestionAppEntityQuery().suggestedEntities() let questions = entities.map { $0.name } guard let question = question else { throw NSError(domain: "", code: -1, userInfo: [NSLocalizedDescriptionKey: "No question provided"]) } let answer = try await sendQuestionToMe(question) print(answer) // Return the response as an IntentResult return .result( dialog: IntentDialog(stringLiteral: answer) ) } } I would like to add a Value Prompt to the perform() function so that the user can input their question before the sendQuestionToMe function is called. Could someone please guide me on how to implement this? Any help would be greatly appreciated. Thank you in advance!
Replies
1
Boosts
0
Views
955
Activity
May ’23
App Intents string type parameter in Shortcut app can't change keyboard
Here is my code : struct NoteIntent: AppIntent { // 3 static var title: LocalizedStringResource = "Write memo" static var openAppWhenRun: Bool = false // 4 @Parameter(title: "Input") var input: String? // 5 @MainActor func perform() async throws -> some ProvidesDialog & IntentResult { guard let providedPhrase = input else { InputViewModel.shared.firstSiriNote = nil throw $input.needsValueError( "Write something") } return .result(dialog: IntentDialog("👏🏻Success!")) } static var parameterSummary: some ParameterSummary { Summary("\(\.$input)") } } My problem is that in Shortcut app input sting parameter only call default keboard,i can't switch third part keyboard or other launguge type
Replies
3
Boosts
0
Views
1.5k
Activity
May ’23
AppIntent Parameter type Duration
Hi, I have developed an iOs app (16+) with SwiftUI. Now I am adding the ability to use voice commands with Siri by creating App Intents. I would like to give users the ability to be able to say, "Siri records 2 hours and 30 for client Mark." For the time part I was thinking of using the @Parameter with data type "Duration" but I get error back and maybe it is not the right type since it accepts seconds as input. What do you recommend? Thanks import Foundation import AppIntents import UIKit struct AddExpense: AppIntent {          static var title: LocalizedStringResource = "Record"          @Parameter(title: "Customer")     var dossier: String          @Parameter(title: "Time")     var tempo: Duration                   func perform() async throws -> some IntentResult & ProvidesDialog  {         //await addExpense()         let dialog = IntentDialog("Ok!")         return .result(dialog: dialog)     } } Error: Generic class 'IntentParameter' requires that 'Duration' conform to '_IntentValue' Warning: Stored property '_tempo' of 'Sendable'-conforming struct 'AddExpense' has non-sendable type '<>' Documentation [https://developer.apple.com/documentation/appintents/providing-your-app-s-capabilities-to-system-services]
Replies
1
Boosts
0
Views
1.8k
Activity
May ’23
App Intents don't show on device, while they do in the simulator
Hello. I want to provide my users with some useful shortcuts and chose AppIntents to do so. I watched the relevant WWDC talks, read the documentation and I set up a few simple intents, adhering to AppIntent. I also created a AppShortcutsProvider to offer the most useful of my intents on installation. I did use \(.applicationName) within my phrases. Trying it out on the simulator, it works as intended (Ventura 13.3, Xcode 14.3, iOS 16.4). Wonderful! Now, building the same code for my hardware device (iPhone SE 3rd Gen, iOS 16.4) and trying it out on there, nothing shows up - neither the intents I want to add on install, nor the ones the user would have to select manually. I really have no idea why... On a side note: My app does have a Watch counterpart and I'd like to do the same there, but with intents specific to the Watch app. They don't even show up in the simulator, though. Any ideas what could've went wrong here? I'd appreciate it. Thanks!
Replies
3
Boosts
0
Views
3.3k
Activity
Apr ’23
AppShortcutsProvider pharses not recognizable by Siri
We have implemented AppIntents in iOS16 and the shortcuts are working fine when manually added in shortcuts app. But the shortcuts created programaticaly using AppShortcutsProvider with AppShortcutsPhrases are not at all recognized by Siri. The AppIntents core feature is zero setup shortcuts, but it is not working as expected. Please suggest any fix for this. Sample Code: struct NotesShortcutProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { let shortcut = AppShortcut(intent: ShowTodayTasks(), phrases: ["Show today tasks","show my tasks today"]) return [shortcut] } } Tried with applicationName as well but no luck.
Replies
4
Boosts
2
Views
2.8k
Activity
Apr ’23
Parent parameters
Is it possible to filter a parameter based on a previous parameter value submitted by the user? Something similar to the parent parameter option available in the intent definition file. What I'm trying is to filter the options in DynamicOptionsProvider based on previous answers submitted by the user.
Replies
1
Boosts
1
Views
1.2k
Activity
Mar ’23
AppEntity Display Issue on Siri Shortcut with AppIntents
My Shortcut is built using the new AppIntents framework for Siri. The problem is subtitles and images on my AppEntity appear when running the shortcut in the shortcuts app, but they do not show up when running on Siri. This is a client requirement and I can't figure out how to fix this. I am using the proper DisplayRepresentation. See images below     .init(title: "\(displayString)", subtitle: "\(fullAddress)",image: imageUrl.isEmpty ? DisplayRepresentation.Image(systemName: "fork.knife.circle.fill") : DisplayRepresentation.Image(url: URL(string: imageUrl )! )) Here's how it appears in Shortcuts: Here's how it appears on SIri:
Replies
0
Boosts
0
Views
1.4k
Activity
Feb ’23
Can I Combine System Actions with Custom Intents to Create a Shortcut in iOS App Development?
Is it possible to create a custom app shortcut using system actions and custom intents in iOS development? For instance, can my app generate a shortcut that combines dictation text, note creation, and speech output using Siri speakers? If not, is there a way to access dictation text or Siri speakers from within my custom app intent?
Replies
0
Boosts
0
Views
829
Activity
Feb ’23
Difference between Custom Intents and App Intents
Hi everyone. Can someone explain the difference between custom intents and app intents, and provide documentation for the type of intent needed to create a shortcut from an installed app with the same functionality as the manual "repeat text" shortcut created on my phone which listens for speech and repeats it using Siri speakers?
Replies
0
Boosts
0
Views
1k
Activity
Feb ’23
LocalizedStringResource with Formatter
I am trying to use DateComponentsFormatter() with my AppIntent, but I can not find a way to localize the formatter string with the same language that LocalizedStringResource use... Example (My App: Arabic, Device: English, Siri: English) let formatter = DateComponentsFormatter()     formatter.unitsStyle = .full     formatter.maximumUnitCount = 2     formatter.allowedUnits = [.hour, .minute]     formatter.includesTimeRemainingPhrase = true let relativeDate = formatter.string(from: .now, to: nextEvent.date) ?? ""      return .result(             value: value,             dialog: "intent_current_event\(relativeDate)"           ) The result is: Next event متبقي 4 ساعات و 5 دقائق The relativeDate is in Arabic (App Language) and the "intent_current_event%@" localized in English (Siri Language) Can anyone please help me to use the Formatter and get it to localized the same local as LocalizedStringResource.
Replies
3
Boosts
0
Views
2.0k
Activity
Dec ’22
App Intent not Discoverable by Siri
I'm implementing the iOS 16 AppIntents framework and it works fine except when I try to trigger it with Siri, which just pulls up results from the web. Here's a very simple version I made on an empty project. import Foundation import AppIntents @available(iOS 16.0, *) struct ShowMeBooks: AppIntent {     static var openAppWhenRun: Bool = false     static var title: LocalizedStringResource = "Show me my books"          func perform() async throws -> some IntentPerformResult {         let x = 1 + 1         return .finished(dialog: "Here are your books")     } } @available(iOS 16.0, *) struct SouthwestShortcuts: AppShortcutsProvider {     static var appShortcuts: [AppShortcut] {         AppShortcut(             intent: ShowMeBooks(),             phrases: ["Show me my books on \(.applicationName)"]         )     } }
Replies
9
Boosts
1
Views
5.5k
Activity
Dec ’22
Asking for AppDependencyManager sample code
Could Apple please share some sample code showing how to use AppDependency and AppDependencyManager with AppIntents? Thanks
Replies
1
Boosts
2
Views
1.3k
Activity
Nov ’22