Dive into App Intents

RSS for tag

Discuss the WWDC22 Session Dive into App Intents

Posts under wwdc2022-10032 tag

8 Posts
Sort by:
Post not yet marked as solved
4 Replies
1.5k Views
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.
Posted
by Subhanc.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
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...
Posted
by wtrnmk12.
Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
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!
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.1k Views
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.
Posted
by Phantom59.
Last updated
.
Post not yet marked as solved
1 Replies
726 Views
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!
Posted
by hprpic.
Last updated
.
Post not yet marked as solved
2 Replies
1.4k Views
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?
Posted Last updated
.
Post not yet marked as solved
2 Replies
896 Views
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
Posted
by lord30590.
Last updated
.
Post not yet marked as solved
1 Replies
1k Views
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]
Posted
by sepu.
Last updated
.