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

Unable to pass parameters from siri phrase to appIntent
I have a chat/search functionality in my app, I want to integrate siri where user can say something "Hey siri! Ask myApp to get latest news" then I want to invoke my search functionality with "get latest news". I see iOS apps like chatGPT and youtube have already achieved this. I am able to invoke the intent with static phrase which is expecting the parameter, user is able to provide the value when prompted after requestValueDialog. But it is a 2 step process for end user. I want to achieve in a single step. struct CombinedSiriShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { return [ AppShortcut( intent: ShowSpecificNewsArticleIntent(), phrases: [ "Ask \(.applicationName) to run a query:", ], shortTitle: "Specific News Article", systemImageName: "doc.text.fill" ), AppShortcut( intent: TestQuery(), phrases: [ "Ask \(.applicationName) to \(\.$query)", ], shortTitle: "Test intent", systemImageName: "doc.text.fill" ), ] } } struct ShowSpecificNewsArticleIntent: AppIntent { static var title: LocalizedStringResource = "Show Specific News Article" static var description = IntentDescription( "Provides details about a specific news article based on its title." ) @Parameter(title: "Query") var query: String @MainActor func perform() async throws -> some IntentResult & ProvidesDialog & ShowsSnippetView { print("in show specific intent"); print(query); return .result(dialog: "view more about: \(query)") } }
0
0
7
2h
Dynamic parameters in shortcuts
I need to have a dynamic parameter for Shortcuts, so a person can say something like Hey Siri, order a pizza with The parameter code in the appIntent is @Parameter(title: "Title") var itemName: String In the Shortcut I use: AppShortcut( intent: NewItemIntent(), phrases: [ "order \(\.$itemName) using \(.applicationName)" ], shortTitle: "Order Item", systemImageName: "sparkles" ) When I call it "hey Siri, order pizza using ***" where pizza should be passed via the parameter then handed off to the appintent. However, it ignores the spoken parameter in lieu of putting up a dialog asking "What's the name?" I can say "pizza" and it now works. How can I pick up the parameter without having to go to that second step as the code implies?
1
0
29
2d
NSUserActivity in application(_:continue:restorationHandler:) not recognized as INStartCallIntent
Hello, experts! I'm working on a VOIP application that handles audio calls and integrates with CallKit. The problem occurs when attempting to redial a previously made audio call from the system's call history. When I try to handle the NSUserActivity in the application(_:continue:restorationHandler:) method, it intercepts the INStartAudioCallIntent instead of the expected INStartCallIntent. Background Deprecation Warnings: I'm encountering deprecation warnings when using INStartAudioCallIntent and INStartVideoCallIntent: 'INStartAudioCallIntent' was deprecated in iOS 13.0: INStartAudioCallIntent is deprecated. Please adopt INStartCallIntent instead. 'INStartVideoCallIntent' was deprecated in iOS 13.0: INStartVideoCallIntent is deprecated. Please adopt INStartCallIntent instead. As a result, I need to migrate to INStartCallIntent instead, but the issue is that when trying to redial a call from the system’s call history, INStartAudioCallIntent is still being triggered. Working with Deprecated Intents: If I use INStartAudioCallIntent or INStartVideoCallIntent, everything works as expected, but I want to adopt INStartCallIntent to align with the current iOS recommendations. Configuration: CXProvider Configuration: The CXProvider is configured as follows: let configuration = CXProviderConfiguration() configuration.supportsVideo = true configuration.maximumCallsPerCallGroup = 1 configuration.maximumCallGroups = 1 configuration.supportedHandleTypes = [.generic] configuration.iconTemplateImageData = UIImage(asset: .callKitLogo)?.pngData() let provider = CXProvider(configuration: configuration) Outgoing Call Handle: When making an outgoing call, the CXHandle is created like this: let handle = CXHandle(type: .generic, value: callId) Info.plist Configuration: In the info.plist, the following key is defined: <key>NSUserActivityTypes</key> <array> <string>INStartCallIntent</string> </array> Problem: When trying to redial the audio call from the system's call history, the NSUserActivity received in the application(_:continue:restorationHandler:) method is an instance of INStartAudioCallIntent instead of INStartCallIntent. This happens even though INStartCallIntent is listed in NSUserActivityTypes in the info.plist and I want to migrate to the newer intent as recommended in iOS 13+. Device: iPhone 13 mini iOS version 17.6.1
0
0
56
3d
App Intents doesn't works in widgets
I’m trying to develop a widget with a button that triggers an app intent. I integrated the app intent into my app within a separate app framework. I tested it with Shortcuts and Siri, and it works well—it opens the app on the required screen. However, when I added a button Button(intent: MyIntent()) to my widget, it doesn’t work at all. The only clue I found is the following message in the Xcode debug console: “No ConnectionContext found for (some big integer)” when I tap on the widget's button. However, I see the same message when running it through the Shortcuts app, and in that case, it works fine. Does anyone know what might be causing this issue? My Intent: public struct OpenTextInputIntent: AppIntent { public static var title: LocalizedStringResource = "Open text input" public static var openAppWhenRun: Bool = true @Parameter(title: "Predefined text") public var predefinedText: String @Dependency private var appCoordinator: AppCoordinatorProtocol public init() { } public func perform() async throws -> some IntentResult { appCoordinator.openAddMessage(predefinedText: predefinedText) return .result() } } My widget's view: struct SimpleWidgetView : View { var entry: SimpleWidgetTimelineProvider.Entry var body: some View { ZStack(alignment: .leadingTop) { button } } private var button: some View { Button(intent: OpenTextInputIntent()) { Image(systemName: "mic.fill") .resizable() .aspectRatio(contentMode: .fit) .iconFrame() } .buttonStyle(PlainButtonStyle()) .foregroundStyle(Color.white) .padding(10) .background(Circle().fill(Color.accent)) } } Intents Registration in the app target: struct MyAppPackage: AppIntentsPackage { static var includedPackages: [any AppIntentsPackage.Type] { [FrameworkIntentsPackage.self] } } struct MyAppShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: OpenTextInputIntent(), phrases: ["Add message in \(.applicationName)"], shortTitle: "Message input", systemImageName: "pencil.circle.fill" ) } } What I'm missing?
0
0
15
1w
AppIntent, should I delete previous donations to the system and how?
Hi, In my application I am donating AppIntent instances that I have to the system using the donate() API. I recently came across this article that talks about deleting donations but it does not mention how to handle AppIntent instances. I am wondering when working with dynamic AppIntents (with different properties that can change in the future), should I be worried about "outdated" donated AppIntent instances? And if yes how can I delete previously donated AppIntent instances.
0
0
160
1w
Swift Playground 4.6 - App Fails to Run with import AppIntent
Hi everyone, I’ve been developing an app using Swift Playgrounds, and it was working fine in version 4.5. However, after updating to Swift Playground 4.6, the app no longer runs. After some testing, I found that the issue occurs when import AppIntent is included. Here’s a simple example: import SwiftUI //import AppIntents // <- If this line is included, Preview and Run fail. @main struct MyApp: App { var body: some Scene { WindowGroup { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) Text("Hello, world!") } } } Has anyone else encountered this issue? Thanks!
2
0
218
1w
Does DynamicOptionsProvider work on watchOS?
I'm curious, why DynamicOptionsProvider is available on watchOS? Is there any way to present options to the user? For example in Emoji Rangers project: struct EmojiRangerSelection: AppIntent, WidgetConfigurationIntent { static let intentClassName = "EmojiRangerSelectionIntent" static var title: LocalizedStringResource = "Emoji Ranger Selection" static var description = IntentDescription("Select Hero") @Parameter(title: "Selected Hero", default: EmojiRanger.cake, optionsProvider: EmojiRangerOptionsProvider()) var hero: EmojiRanger? struct EmojiRangerOptionsProvider: DynamicOptionsProvider { func results() async throws -> [EmojiRanger] { EmojiRanger.allHeros } } func perform() async throws -> some IntentResult { return .result() } } On watchOS we usually use recommendations() to give the user predefined choice of configured widgets. Meanwhile in AppIntentProvider recommendations are empty: struct AppIntentProvider: AppIntentTimelineProvider { ... func recommendations() -> [AppIntentRecommendation<EmojiRangerSelection>] { [] } } Does it imply that there's a way to use DynamicOptionsProvider on watchOS somehow? BTW, WidgetConfiguration.promptsForUserConfiguration() is one of the methods that are not available on watchOS. And also, the Emoji Ranger project doesn't show widgets (complications) on watchOS out of the box.
0
2
202
2w
Siri Shortcut Phrases iOS -17
I made a set of Siri Shortcuts in my app with the AppShortcutsProvider, and they each have a set of phrases. I can activate the shortcuts via Siri phrases or Spotlight search on iOS 18+, but not on iOS -17. I've checked the documentation and see that AppShortcutsProvider is supported from iOS 16+, so I don't understand why I can't view the shortcuts in Spotlight or activate them with Siri unless it's at least iOS 18. Any thoughts?
3
0
216
1d
Start multiple Live Activities in the perform() of App Intents
In my case, when two functions that start each Live Activity(not connected each other) are performed in LiveActivityIntent's perform(), it seems that only one will start. (It's the same to start independently with two Task{}) And, set one to 'opensIntent' and separate it by opening another LiveActivityIntent, the result is same. Also, every time I tap the Intent directly in the shortcut app, one activity will end within a matter of seconds, even if there are two for a while. But, If openAppWhenRun to true, it seem to works without any problems. I would appreciate it if you could give me a tip to fix this problem.
0
0
107
2w
WidgetInfo - intent is nil until edit face
We have a watchOS app that provides many configurable widgets. Those widgets are configured and installed with help of AppIntent: public struct RectComplAppIntent: AppIntent, WidgetConfigurationIntent, CustomIntentMigratedAppIntent { @Parameter(title: "Style") var style: String? .... } However when I print WidgetInfos with getCurrentConfigurations(), I sometimes got nil for configuration. At the same time widgets are not loaded. Exact steps: User installs the pre-cofnigured .watchface. Complications are not loaded since configuration is missing. I print getCurrentConfigurations() and get entries like this: WidgetInfo: - configuration: nil - widgetConfigurationIntent: nil - family: accessoryRectangular - kind: Rectangle Then user force-touches a face and opens editing mode. Returns to watch app, prints infos: WidgetInfo: - configuration: <INIntent: 0x780d290> { style = vol1Logo; } - widgetConfigurationIntent: nil - family: accessoryRectangular - kind: Rectangle – Suddenly intent appears with the correct style and complications start to show up. How do you think, why it happens? Why after .watchface install all the WidgetInfo has nil intent (configuration)? What helps them to load later? You can try this face yourself: https://cdn.watchfaces.co/watchfaces/glance-minimalist.watchface
1
0
193
1w
Complications Appear Unnamed in Watch App After Syncing .watchface File
When using my app's complications with either Siri Intents or App Intents after syncing .watchface files, the complications appear without names in the iOS Watch app's complication picker. This leads to complications showing as blank entries without previews in the native watch app selector. I'm using WidgetKit to create Watch complications with both approaches: AppIntents and Siri Intents. We've tried multiple approaches with our WidgetKit watch complications: Switching between IntentConfiguration and StaticConfiguration Using different naming conventions for kind strings Ensuring display names are properly set Testing across different watchOS versions But the result is always the same: after syncing .watchface files, our complications appear unnamed in the Watch app's complication picker. Is this a known limitation with .watchface syncing, a bug in the current implementation, or is there a specific requirement we're missing to maintain complication names during the sync process?
2
3
319
4d
Group AppIntents’ Searchable DynamicOptionsProvider in Sections
I’m trying to group my EntityPropertyQuery selection into sections as well as making it searchable. I know that the EntityStringQuery is used to perform the text search via entities(matching string: String). That works well enough and results in this modal: Though, when I’m using a DynamicOptionsProvider to section my EntityPropertyQuery, it doesn’t allow for searching anymore and simply opens the sectioned list in a menu like so: How can I combine both? I’ve seen it in other apps, but can’t figure out why my code doesn’t allow to section the results and make it searchable? Any ideas? My code (simplified) struct MyIntent: AppIntent { @Parameter(title: "Meter"), optionsProvider: MyOptionsProvider()) var meter: MyIntentEntity? // … struct MyOptionsProvider: DynamicOptionsProvider { func results() async throws -> ItemCollection<MyIntentEntity> { // Get All Data let allData = try IntentsDataHandler.shared.getEntities() // Create Arrays for Sections let fooEntities = allData.filter { $0.type == .foo } let barEntities = allData.filter { $0.type == .bar } return ItemCollection(sections: [ ItemSection("Foo", items: fooEntities), ItemSection("Bar", items: barEntities) ]) } } struct MeterIntentQuery: EntityStringQuery { // entities(for identifiers: [UUID]) and suggestedEntities() functions func entities(matching string: String) async throws -> [MyIntentEntity] { // Fetch All Data let allData = try IntentsDataHandler.shared.getEntities() // Filter Data by String let matchingData = allData.filter { data in return data.title.localizedCaseInsensitiveContains(string)) } return matchingData } }
0
0
483
3w
Siri Intent Dialog with custom SwiftUIView not responding to buttons with intent
I have created an AppIntent and added it to shortcuts to be able to read by Siri. When I say the phrase, the Siri intent dialog appears just fine. I have added a custom SwiftUI View inside Siri dialog box with 2 buttons with intents. The callback or handling of those buttons is not working when initiated via Siri. It works fine when I initiate it in shortcuts. I tried using the UIButton without the intent action as well but it did not work. Here is the code. static let title: LocalizedStringResource = "My Custom Intent" static var openAppWhenRun: Bool = false @MainActor func perform() async throws -> some ShowsSnippetView & ProvidesDialog { return .result(dialog: "Here are the details of your order"), content: { OrderDetailsView() } } struct OrderDetailsView { var body: some View { HStack { if #available(iOS 17.0, *) { Button(intent: ModifyOrderIntent(), label : { Text("Modify Order") }) Button(intent: CancelOrderIntent(), label : { Text("Cancel Order") }) } } } } struct ModifyOrderIntent: AppIntent { static let title: LocalizedStringResource = "Modify Order" static var openAppWhenRun: Bool = true @MainActor func perform() async throws -> some OpensIntent { // performs the deeplinking to app to a certain page to modify the order } } struct CancelOrderIntent: AppIntent { static let title: LocalizedStringResource = "Cancel Order" static var openAppWhenRun: Bool = true @MainActor func perform() async throws -> some OpensIntent { // performs the deeplinking to app to a certain page to cancel the order } } Button(action: { if let url = URL(string: "myap://open-order") { UIApplication.shared.open(url) } }
0
0
245
3w
App Transfer and Siri Shortcuts Intents backwards compatibility
Hi, I am currently working on an App Transfer from Company A to Company B but can't find any documentation about what happens to existing Siri Shortcuts working via App Extension intents. I have separated the rest of the post in 2 sections: one what summarizes my current understanding and the other with some questions and hypotheses. It would be great to have either someone from Apple to answer that, or someone else share their experience and possibly some documentation that I might have missed. To my understanding, when a new Shortcut is created, it stores the BundleID of the App and of the App Extension to find the application that will execute it afterwards. If I uninstall the App, I can see a message in the Shortcut app that says "This action requires APPNAME but it may not be installed", but I know that after transferring the app the BundleID doesn't change completely, only the team part does. However, it is not possible to test that as this change cannot be done in xCode as far as I know. Another part that seems to play a role here is the info.plist file, but in my situation, there are no entries related to the BundleID. All that being said, I am wondering: Is it possible to perform an app transfer and keep previously created shortcuts working? Is it possible to test this kind of things without having to perform a transfer? I haven't found a way to change the team part of the Bundle ID Is there a place in the documentation that takes care of those things in depth?
0
0
280
3w
SIri trigger command conflicts
We're having trouble with getting Siri to hand off specific trigger words to our app via shortcuts. I want to be able to say "Hey Siri Myappname Foobar" but in some cases if Foobar is the name of a specific business it may launch maps instead showing locations of those businesses. Is there any way to inform Siri, "no, *****, launch our app as the shortcut specifies!"
0
0
200
3w