Post not yet marked as solved
I am trying to create a shortcut following "Implement App Shortcuts With App Intents" talk from WWDC2022.
The below is my MWE. In a standalone app, this can be extended and behave like the video. Adding this code to my main app, makes the shortcut show up within the Shortcuts app, but if I click on it, it pops up an alert saying
Error Domain=LNActionForAutoShortcutPhraseFetchError Code=1 "Couldn't find AppShortcutsProvider" UserInfo={NSLocalizedDescription=Couldn't find AppShortcutsProvider}
My main app has several targets, so I suppose I need to establish which one is the shortcuts provider, but I cannot find any reference to how to do this in the documents.
Via Siri, the shortcut command is not recognised at all.
import AppIntents
import SwiftUI
struct DoSomething: AppIntent {
static var title: LocalizedStringResource = "Do something"
func perform() async throws -> some IntentResult {
return .result()
}
static var openAppWhenRun: Bool = false
}
struct MyShortcuts: AppShortcutsProvider {
@AppShortcutsBuilder
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: DoSomething(),
phrases: ["Do Something in \(.applicationName)"],
systemImageName: "books.vertical.fill"
)
}
}
Post not yet marked as solved
Hi, according this WWDC session https://developer.apple.com/wwdc22/10170
App Shortcuts are defined in Swift code, by implementing the AppShortcutsProvider protocol. To implement the protocol, I'll simply create a single getter that returns all the app shortcuts I want to set up for the user. Note that in total, your app can have a maximum of 10 app shortcuts. However, most apps only need a few.
there is a limit for up to 10 AppShortcuts. Could you please clarify how that limit handled? 🤔 (e.g. project failed to build / app will crash or malfunction / only 10 shortcuts will be handled on random/ordered choice by iOS) I suppose there is some way to manage shortcuts amount but see no details at documentation yet.
When using just the application name in a phrase, it works great and the shortcut can be invoked via Siri:
e.g. "Show books in \(.applicationName)" // This works
But introducing a parameter in a phrase fails to create a working shortcut that can be invoked via Siri:
e.g. "Show \(\.$book) in (\.applicationName)" // Does not work
where $book is a parameter for BookEntity in my intent.
i am calling updateAppShortcutParameters() and i only have a single book titled "Frankenstein". When my App is launched after a fresh install, i can see that a shortcut is automatically created in the Shortcuts App but has the following title:
"Show %@ in MyAppName"
Even though the title looks incorrect, tapping the shortcut works and the correct book title is passed to my Intent. However, i cannot invoke the shortcut using Siri. i.e. saying "Show Frankenstein in MyAppName" does not work.
Has anyone run into this particular issue? i am running Xcode 14 Beta 6 and iOS 16 Beta 7 on my iPhone. Also tested in iOS Simulator and got the same results.
This is arguably the biggest selling point for App Shortcuts (zero setup required by the user) so i am hoping it is addressed before iOS 16 becomes officially available.
Post not yet marked as solved
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?
Post not yet marked as solved
Is there any way a live activity could be started from a shortcut? The example live activities (ordering a ride share, viewing sports scores etc) are good fits for shortcuts and live activities but I'm not able to start a live activity from a shortcut using the new app intents framework.
Is it possible to start a live activity from an app intent shortcut?
Post not yet marked as solved
I'm trying to implement App Intents and App Shortcuts on watchOS. To do that, I included my AppIntent and my AppShortcutsProvider to the WatchKit extension target. The intent has one variable parameter:
@Parameter(title: "Category",
description: "Category",
requestValueDialog: "What are you searching for?")
var category: String
However, when I speak the invocation phrase to Siri on the watch, Siri immediately responds there's something wrong. My perform() method isn't even called and there's nothing in the log.
Is this supposed to work? How could I debug this? Is there a sample app showing App Intents on watchOS?
Post not yet marked as solved
Prior to iOS 16, Intent Handlers in SiriKit only had 10 seconds to complete the request. However, i have not come across any mention of a time limit in the documentation for the new AppIntents framework.
My own testing revealed this limit to be somewhere between 20-25 seconds.
Does anyone know what the official time limit is to complete a request with the new AppIntents framework?
Post not yet marked as solved
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.
Post not yet marked as solved
I need to set the openAppWhenRun:Bool dynamically in App Intent. Eventhough I set this way. the app does not open when run the shortcut automation.
static var openAppWhenRun:Bool { myNumber == 4 ? true : false }
Post not yet marked as solved
In Design App Shortcuts, Lynn shows a slide at 11:54 where a shortcut with a custom view has "suppressed" the dialog.
How can we achieve this? I can't find any actual examples.
Post not yet marked as solved
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!
Post not yet marked as solved
Recently (I think when updated to Xcode 14.3) my macOS Shortcut actions
(implemented via AppIntent) started having a problem:
When I click an action's AppEntity parameter I see the following error instead of seeing a list of entries to select from.
The action “Demo Action” could not run because an internal error occurred.
One difference that I notice between my builds that didn't exhibit this error and my builds that do exhibit the error:
Working builds include objects.appintentsmanifest in the metadata folder
Builds that break with the above behavior do not include that file
Did something change in recent Xcode? What do I need to do so that Shortcuts app will run my queries again and provide popups so that I can select queried AppEnties?
To recreate the problem I created a new Document Based App in Xcode 14.3 and included the following code. I then dragged "Demo Action" into a new Shortcut and clicked "Show More" and then clicked "Books: Choose".
import AppIntents
struct BookEntity: Identifiable, AppEntity {
var id: UUID
@Property(title: "Title")
var title: String
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(title: LocalizedStringResource(stringLiteral: title))
}
init(id: UUID, title: String?) {
self.id = id
self.title = title ?? "Unknown Title"
}
static var typeDisplayRepresentation: TypeDisplayRepresentation = "Book"
static var defaultQuery = BookQuery()
}
struct BookQuery: EntityStringQuery {
func entities(for identifiers: [UUID]) async throws -> [BookEntity] {
library.filter { identifiers.contains($0.id) }
}
func entities(matching query: String) async throws -> [BookEntity] {
library.filter { $0.title.localizedCaseInsensitiveContains(query) }
}
func suggestedEntities() async throws -> [BookEntity] {
library
}
}
struct DemoAction: AppIntent {
static var title: LocalizedStringResource = "Demo Action"
@Parameter(title: "Books")
var books: [BookEntity]
func perform() async throws -> some IntentResult {
.result()
}
}
let library: [BookEntity] = [
BookEntity(id: UUID(), title: "The Hobbit"),
BookEntity(id: UUID(), title: "The Lord of the Rings"),
]
Post not yet marked as solved
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...
Post not yet marked as solved
We have a simple AppIntent to let users ask a question in our app.
The intent has a single parameter: Prompt which is retrieved by a requestValueDialog.
Users have reported that when using Siri, the dialog for "What would you like to ask?" appears, but if they respond with phrases such as "What is the last album by Sting" it just presents the dialog for the prompt again.
Testing it, I find that I can reproduce the behavior if I include words like "recent" or "last". Just providing those words in isolation causes the dialog to be presented over and over again.
Using the same intent from Shortcuts does not seem to have that limitation, it's only when providing the spoken words for speech recognition.
All of that interaction happens outside our code, so I cant see any way to debug or identify why the prompts are being rejected. Is there a different way to specify the @Parameter to indicate the prompt: String could include any arbitrary text - including "recent" or "last" ?
My hunch is those words are triggering a system response that is stepping on the requstValueDialog?
Here's the basics of how the intent and parameter are setup:
struct AskAI: AppIntent {
static var title: LocalizedStringResource = "Ask"
static var description: IntentDescription = IntentDescription("This will ask the A.I. app")
static var openAppWhenRun = false
@Parameter(title: "Prompt", description: "The prompt to send", requestValueDialog: IntentDialog("What would you like to ask?"))
var prompt: String
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog & ShowsSnippetView {
var response = ""
...
response = "You asked: \"\(prompt)\" \n"
...
return .result(dialog: "\(response)")
}
static var parameterSummary: some ParameterSummary {
Summary("Ask \(\.$prompt)")
}
}
I am working on a swiftui with sirikit. Intent and IntentUI.
Often find that the IntentUI is not working. It shows only the default screen and bring user into the app. But not the customized IntentUI.
I find that many developers online those worked on siri also have similar problem. Want to know is there a promising way that it will show the customized UI Everytime with siri input (come from shortcuts).
And I often find that it works last time i checked it. And then after I worked on other functionalies (which are inrelevant to siri) and come back, the siri IntentUI doesn't work again. This is frustrating. Any clue?
Thanks.
Attached image is the default UI shown, which means the IntentUI didn't work.
Post not yet marked as solved
I added siri suggestion to the app for a while,it works well.But some day,as shown in the picture,when I clicked on my siri suggestion, it opened another app. If the system showed siri suggestion to my app, why did it open another app by mistake? Can someone tell me what the reason is?
Post not yet marked as solved
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
Post not yet marked as solved
Hi there,
After a crash the log contained the following events that look to my newbie eyes to be a call to SIRI for my configuration files; looking for other mentions of this crash log message brought me here to the development forums and included not only what appears to be a possible call to SIRI but also a possible call to a specific message to be "dictated" to SIRI. I don't know what this means but my *** radar is going off.
Original crash log entries (Logic Pro X crashing)
"legacyInfo" : {
"threadTriggered" : {
"queue" : "com.apple.main-thread"
}
},
"logWritingSignature" : "76f7997036f9874763e329de45d64ba64b5b5964",
"trialInfo" : {
"rollouts" : [
{
"rolloutId" : "62699e1ec1ff297(***)",
"factorPackIds" : {
"SIRI_FIND_MY_CONFIGURATION_FILES" : "631f72d1de5591(***)"
},
"deploymentId" : 240000023
},
{
"rolloutId" : "6391cacc75b072(***),
"factorPackIds" : {
"COREOS_ICD" : "63957ec73127f(***)"
},
"deploymentId" : 240000007
}
],
"experiments" : [
]
}
^^ In the above log, please note "SIRI_FIND_MY_CONFIGURATION_FILES"
In another posted error log in this Apple forum (https://developer.apple.com/forums/thread/706908), SIRI_FIND_MY_CONFIGURATION_FILES was posted as well as a following call to "SIRI_DICTATION_ASSETS".
Excuse me wut?
Post not yet marked as solved
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!
Post not yet marked as solved
Hi all,
I'm trying to update my app to use the AppIntent framework to play an audio file (loaded from the main bundle).
I tried implementing an a PlayMusicIntent using the AudioStartingIntent protocol, but have had no luck. The intent does run, and provides the dialog response, but the music doesn't start.
struct PlayMusicIntent: AudioStartingIntent {
static let title:LocalizedStringResource = "Play Music"
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog {
guard let musicPath = Bundle.main.url(forResource: "moonglow", withExtension: "mp3") else { fatalError("Could not load music file") }
do {
let musicPlayer = try AVAudioPlayer(contentsOf: musicPath)
musicPlayer.numberOfLoops = -1
musicPlayer.play()
return .result(dialog: "Now Playing Moonglow")
}catch {
print(error)
return .result(dialog: "There was an error playing the music: \(error.localizedDescription)")
}
return .result(dialog: "Cannot play music")
}
}
And then add this in my App Shortcuts Provider:
AppShortcut(intent: PlayMusicIntent(), phrases: [
"Play music with \(.applicationName)"
])
I do have Audio background mode enabled. I'm thinking I need to do something with the intent's return type, but there is not a lot of documentation or online examples to implement AudioStartingIntent
Any suggestions would be appreciated.
Thanks,
Scott