App Intents

RSS for tag

Extend your app’s custom functionality to support system-level services, like Siri and the Shortcuts app.

Posts under App Intents tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

AppIntents: Shortcuts phrases with parameters are not resolving correctly
Exploring AppIntents and Shortcuts. No matter what I try Siri won't understand parameters in an initial spoken phrase. For example, if I ask: "Start my planning for School in TestApp", Siri responds: "What's plan?", I say: "School" and Siri responds "Ok, starting Shool plan" What am I missing so it won't pick up parameters right away? Logs inside func entities(matching string: String) are only called after "What's plan?" question and me answering "School". No logs after the initial phrase Tried to use Apple's Trails example as a reference but with no luck
1
0
91
4d
Making onscreen content available to Siri not requesting my Transferable
Howdy, I'm following along with this sample: https://developer.apple.com/documentation/appintents/making-onscreen-content-available-to-siri-and-apple-intelligence I've got everything up and building. I can confirm that the userActivity modifier is associating my App Intent via EntityIdentifier but my custom Transferable representation (text) is never being called and when Siri is doing the ChatGPT handoff, it's just offering to send a screenshot which is what it does when it has no custom representation. What could I doing wrong? Where should I be looking?
3
0
207
6d
How to use a Decimal as @Property of AppEntity
I’m trying to use a Decimal as a @Property in my AppEntity, but using the following code shows me a compiler error. I’m using Xcode 16.1. The documentation notes the following: You can use the @Parameter property wrapper with common Swift and Foundation types: Primitives such as Bool, Int, Double, String, Duration, Date, Decimal, Measurement, and URL. Collections such as Array and Set. Make sure the collection’s elements are of a type that’s compatible with IntentParameter. Everything works fine for other primitives as bools, strings and integers. How do I use the Decimal though? Code struct MyEntity: AppEntity { var id: UUID @Property(title: "Amount") var amount: Decimal // … } Compiler Error This error appears at the line of the @Property definition: Generic class 'EntityProperty' requires that 'Decimal' conform to '_IntentValue'
1
0
146
1w
Basic app intent always showing error in Shortcuts app "The action could not run because an internal error occurred."
I have a very basic App Intent extension in my macOS app that does nothing than accepting two parameters, but running it in Shortcuts always produces the error "The action “Compare” could not run because an internal error occurred.". What am I doing wrong? struct CompareIntent: AppIntent { static let title = LocalizedStringResource("intent.compare.title") static let description = IntentDescription("intent.compare.description") static let openAppWhenRun = true @Parameter(title: "intent.compare.parameter.original") var original: String @Parameter(title: "intent.compare.parameter.modified") var modified: String func perform() async throws -> some IntentResult { return .result() } }
2
0
213
1w
Testing app intents and forcing Shortcuts app to refresh
The Verify the behavior of your intent in Simulator or on-device documentation says that it's sufficient to build and run the app and open the Shortcuts app to test an app intent, but that doesn't seem to be the case. I always needed to at least move the debugged app to the Applications folder before the app intents showed up in Shortcuts, and even then, most of the times I also need to wait a lot or restart the Mac. When updating an existing app intent (for instance by changing its title), building the app, overwriting the existing one in the Applications folder and restarting Shortcuts is not sufficient to make the new title appear in Shortcuts. Is there an efficient way to test app intents in the Shortcuts app? I already created FB15638502 one month ago but got no response.
0
0
115
2w
App Intent title and other localized strings not showing correctly in Shortcuts app on macOS 15
I rarely use the Shortcuts app, so it took me a while to notice that my app's app intents all show incorrectly on macOS 15. On macOS 14 and 13, they used to show correctly, but now it seems that all localized strings show the key rather than the localized value. @available(iOS 16.0, macOS 13.0, *) struct MyAppIntent: AppIntent { static let title = LocalizedStringResource("key1", comment: "") static let description = IntentDescription(LocalizedStringResource("key2", comment: "")) ... } In Localizable.xcstrings file I have defined all the strings, for instance I have associated key1 with the value Title, but while the Shortcuts app used to display Title, it now displays key1. Is this a known issue or did something change in macOS 15 that would require me to update something?
4
0
113
3d
Intents not showing up in WatchOS Shortcuts
I have developed a standalone WatchOS app which runs a stopwatch. I want to develop a shortcut that launches the stopwatch. So far I have created the Intent file, and added the basic code (shown below) but the intent doesn't show in the shortcuts app. In the build, I can see the intent metadata is extracted, so it can see it, but for some reason it doesn't show in the watch. I downloaded Apple's demo Intent app and the intents show in the watch there. The only obvious difference is that the Apple app is developed as an iOS app with a WatchOS companion, whereas mine is standalone. Can anyone point me to where I should look for an indicator of the problem? Many thanks! // // StartStopwatch.swift // LapStopWatchMaster import AppIntents import Foundation struct StartStopWatchAppIntent: AppIntent { static let title: LocalizedStringResource = "Start Stopwatch" static let description = IntentDescription("Starts the stopwatch and subsequently triggers a lap.") static let openAppWhenRun: Bool = true @MainActor func perform() async throws -> some IntentResult { // Implement your app logic here return .result(value: "Started stopwatch.") } }
3
0
159
1w
Why is applicationWillEnterForeground called on first launch when using AppIntent with openAppWhenRun = true?
Hello, I’ve implemented a feature in my app using AppIntent. When the app is not running in the background and is launched for the first time via a shortcut, both application:didFinishLaunchingWithOptions: and applicationWillEnterForeground: are called. Normally, on the first launch, applicationWillEnterForeground: is not invoked. However, this behavior seems to occur only when the app is launched through a shortcut. I’d like to understand why applicationWillEnterForeground: is being called in this scenario. For reference, the AppIntent has openAppWhenRun set to true. Thank you in advance for your help!
1
0
201
1w
Why is applicationWillEnterForeground called on first launch when using AppIntent with openAppWhenRun = true?
Hello, I’ve implemented a feature in my app using AppIntent. When the app is not running in the background and is launched for the first time via a shortcut, both application:didFinishLaunchingWithOptions: and applicationWillEnterForeground: are called. Normally, on the first launch, applicationWillEnterForeground: is not invoked. However, this behavior seems to occur only when the app is launched through a shortcut. I’d like to understand why applicationWillEnterForeground: is being called in this scenario. For reference, the AppIntent has openAppWhenRun set to true. Thank you in advance for your help!
3
0
238
2w
Parametrized Shortcuts do not show up in Shortcuts app and search with localisation.
Hi! When my device is set to English, both search and the Shortcuts up automatically show multiple shortcuts parametrised for each value of the AppEnum - which is what I expected. When my device is set to German, I get only the basic AppShortcut without the (optional) parameter. I am using an AppEnum (see below) for the parametrised phrases and localise the phrases into German with an AppShortcuts String Catalog added to my project. Everything else seems to work, I can use my AppShortcut in the Shortcuts app and invoke it via Siri in both English and German. The Shortcuts app displays the values correctly using the localized strings. Any ideas? import AppIntents class ApolloShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: GetIntent(), phrases: [ "Get data from \(.applicationName)", "Get data from \(.applicationName) for \(\.$day)", "Get data from \(.applicationName) for the \(\.$day)" ], shortTitle: "Get Data", systemImageName: "wand.and.sparkles") } } enum ForecastDays: String, AppEnum { static var typeDisplayRepresentation: TypeDisplayRepresentation = "Day" static var caseDisplayRepresentations: [Self : DisplayRepresentation] = [ .today: DisplayRepresentation(title: LocalizedStringResource("today", table: "Days")), .tomorrow: DisplayRepresentation(title: LocalizedStringResource("tomorrow", table: "Days")), .dayAfterTomorrow: DisplayRepresentation(title: LocalizedStringResource("dayAfterTomorrow", table: "Days")) ] case today case tomorrow case dayAfterTomorrow var displayName: String { String(localized: .init(rawValue), table: "Days") } }
1
0
168
3w
Should new apps use AudioPlaybackIntent or INPlayMediaIntent?
WWDC videos suggest that existing apps should continue using the old SiriKit domains, such as INPlayMediaIntent. But what about new apps for playing audio? Should we implement Siri functionality for audio playback using the old SiriKit domains, or should we create our own AppEntities and trigger them via custom AudioPlaybackIntent implementations? Interactive widgets require an AppIntent and don’t support the old INPlayMediaIntent. To achieve the same functionality as the Music app widgets, it seems logical to adopt the new AudioPlaybackIntent. However, I can't find any information about this in the documentation.
1
0
200
Nov ’24
Localized App Shortcuts phrases don't work with AppIntents consumed from a Framework
Imagine we have an Xcode workspace containing two projects: MyLibrary.xcodeproj holding a framework target MyShortcutsApp.xcodeproj holding an app target which consumes MyLibrary framework Both targets define App Intents and the ones from MyLibrary are exposed via AppIntentsPackage accordingly. When trying to wrap the App Intent from framework as App Shortcut and passing localized AppShortcutPhrases I do see the following compile error: ".../Resources/de.lproj/AppShortcuts.strings:11:1: error: This AppShortcut does not map to a known action (MyLibraryIntent specified). (in target 'MyShortcutsApp' from project 'MyShortcutsApp')" If I use the same localized App Shortcut phrases for an App Intent which is locally defined in the app target, everything works fine and also if I use the framework-provided App Intent in and App Shortcut without passing any localized phrases. This is happening with Xcode 16.0 (16A242d), with 16.1 (16B40) and with 16.2 beta 2 (16C5013f). I already raised this issue via FB15701779 which contains a sample project to reproduce and to further analyze the issue. Thanks for any hint on how to solve that. Frank
1
4
265
2w
iOS 18 Siri Shortcut with a phrase does not appear in Shortcuts App any more
I was able to add shortcuts with parameters and use them from the Shprtcuts app in iOS 17, nevertheless Siri intent did never work. I upgraded to iOS 18 my app and my mobile. Now, the shortcut only appears in shortcuts app if no parameter is added to it. When I try to set a parameter, the shortcut does not appear any mora in Shortcuts app. struct ShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: OpenAppIntent(), phrases: [ "Show (.$screen) in (.applicationName)" ], shortTitle: "Open", systemImageName: "iphone.badge.play" ) } } struct OpenAppIntent: AppIntent { static var title: LocalizedStringResource = "Show" static let description = IntentDescription("Shows a screen.") static var openAppWhenRun: Bool = true static var authenticationPolicy = IntentAuthenticationPolicy.alwaysAllowed @Parameter(title: "screen") var screen: String @MainActor func perform() async throws -> some IntentResult { return .result() } } extension ScreenOption: AppEntity { struct OpenAppQuery: EntityQuery { @IntentParameterDependency<OpenAppIntent>( \.$screen ) var openAppIntent func entities(for: [ScreenOption.ID]) async throws -> [ScreenOption] { return [] } func suggestedEntities() async throws -> [ScreenOption] { return [] } } var displayRepresentation: DisplayRepresentation { .init(stringLiteral: "\(title)") } static var defaultQuery: OpenAppQuery = OpenAppQuery() static var typeDisplayRepresentation: TypeDisplayRepresentation = .init(name: "Screen") } extension ScreenOption: EntityIdentifierConvertible { static func entityIdentifier(for entityIdentifierString: String) -> ScreenOption? { allCases.filter { $0.rawValue == entityIdentifierString }.first } public var entityIdentifierString: String { rawValue } public init?(entityIdentifierString: String) { guard let screenOption = ScreenOption.entityIdentifier(for: entityIdentifierString) else { return nil } self = screenOption } }
1
0
361
Nov ’24