Share intents from within an app to drive system intelligence and show the app's actions in the Shortcuts app.

Posts under Intents tag

58 Posts
Sort by:
Post not yet marked as solved
0 Replies
351 Views
Hello, I have a question regarding app Intents. I have a simple App Intent and it is working as expected (I can see it in shortcuts and the action shows a phrase and opens my app). I would now want to ask the user for an "App" parameter, that would be any app the user has downloaded on his iPhone. Here my example intent: struct SayPhraseIntent: AppIntent { static var title: LocalizedStringResource = "See a text." static var description = IntentDescription("Just says whatever text you type in.") @Parameter(title: "Text") var text: String? func perform() async throws -> some ProvidesDialog { guard let providedText = text else { throw $phrase.needsValueError("What text do you want to see?") } return .result(dialog: IntentDialog(stringLiteral: providedText)) } } An example of a shortcut that asks this is I have seen some apps do it so it must be possible, but I cannot find anywhere the Type of the @Parameter I would need to get that from a user through the shortcut app. Any help or suggestions would be appreciated.
Posted Last updated
.
Post not yet marked as solved
1 Replies
506 Views
Hi there, I'm trying to use an enum as a @Parameter for my Widget configuration: enum InteractivePlacesWidgetMode: Int, CaseIterable, AppEnum, Comparable, Equatable { typealias RawValue = Int case favourites = 0, recents, nearbyCategory, collections static var typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(name: LocalizedStringResource("Mode")) static var caseDisplayRepresentations: [InteractivePlacesWidgetMode: DisplayRepresentation] = [ .favourites: DisplayRepresentation(title: LocalizedStringResource("Favorites")), .recents: DisplayRepresentation(title: LocalizedStringResource("Recents")), .nearbyCategory: DisplayRepresentation(title: LocalizedStringResource("Categories")), .collections: DisplayRepresentation(title: LocalizedStringResource("Collections")) ] static func < (lhs: InteractivePlacesWidgetMode, rhs: InteractivePlacesWidgetMode) -> Bool { lhs.rawValue < rhs.rawValue } static func == (lhs: InteractivePlacesWidgetMode, rhs: InteractivePlacesWidgetMode) -> Bool { lhs.rawValue == rhs.rawValue } } Then on the ConfigurationAppIntent I would like to show some more option only for specific cases, with the following: struct ConfigurationAppIntent: WidgetConfigurationIntent { static var title: LocalizedStringResource = "Configuration" static var description = IntentDescription("Choose what to show") @Parameter(title: LocalizedStringResource("Show"), default: .favourites) var widgetMode: InteractivePlacesWidgetMode @Parameter (title: "Category") var category: CategoryDetail? static var parameterSummary: some ParameterSummary { When(\.$widgetMode, .equalTo, .nearbyCategory) { Summary { \.$widgetMode \.$category } } otherwise: { Summary { \.$widgetMode } } } } But the widget seems to ignore the When clausole at all. Is this a limitation of the When clausole? Is there something wrong with my approach? I already used that with standard types in previous work and it seems to work quite well. Thanks in advance for your help. c.
Posted
by sofapps.
Last updated
.
Post not yet marked as solved
0 Replies
308 Views
My goal is to have pre-made shortcuts with singular app intents, so my customers won't need to create their own shortcuts. I am using the new AppIntents API, which became available last year. I have 3 app intents, which are working as expected. I am using AppShortcutsProvider to advertise my intense as Siri Shortcuts I have updated my AppShortcutsProvider implementation struct LibraryAppShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { let drink1 = AppShortcut(intent: LogFirstDrink(), phrases: ["\(.applicationName) log first favourite"], shortTitle: "Log 1st favourite", systemImageName: "1.circle") let customDrink = AppShortcut(intent: LogLabelledDrink(), phrases: ["\(.applicationName) log any favourite"], shortTitle: "Log any favourite", systemImageName: "cup.and.saucer") let drink1CustomDate = AppShortcut(intent: LogFirstDrinkAtCustomDate(), phrases: ["\(.applicationName) log first favourite with date"], shortTitle: "Log 1st favourite", systemImageName: "1.square") return [drink1, drink1CustomDate, customDrink] } } ❌ I don't see my app shortcut in the "All Shortcuts" tab (AKA "Shortcuts), the first tab ❌ Sadly, I don't see my app in the beautiful iOS 17 "Suggestions From Your Apps" rectangular views either. Here's an example from Drafts. ❌ I don't see my intents/shortcuts at Spotlight. ✅ I can create custom shortcuts and browse my intents through the "Add Action" flow.
Posted
by borisy.
Last updated
.
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
0 Replies
445 Views
Was watching this latest WWDC 2023 video and had a question. I see about 17:20 in, they mention you can now put the shortcut provider in an app intent extension. https://developer.apple.com/videos/play/wwdc2023/10103/ This works fine by itself and I can see all my shortcuts and use siri, but as soon as I try to call into the extension from the main app in order to trigger updateAppShortcutParameters() or any other code, I get a linker error. Am I doing something obvious wrong? Note, I called it a framework, but it Is just an extension. Cant figure out how I am supposed to be calling this method. Any help is greatly appreciated! https://developer.apple.com/documentation/appintents/appshortcutsprovider/updateappshortcutparameters()?changes=_4_8 https://imgur.com/a/yDygSVJ
Posted Last updated
.
Post not yet marked as solved
6 Replies
921 Views
Hi all, I'm working on a really basic counter app as a way to explore SwiftData and have come across some behavior that I don't understand. I have a very simple App Intent that increments a user-specified counter in my app. The intent doesn't throw any errors and correctly updates the CoreData store but, when I switch back to my app from the Shortcuts app (where I'm testing the app intent), the view hasn't updated. Closing and re-opening the app shows the incremented counter value but I'd like to know if it's possible to have my app's UI update when the CoreData store is updated from outside the app without relaunching the whole app. For some brief context, here's my view and the App Intent: struct ContentView: View { @Environment(\.modelContext) private var modelContext @Query private var counters: [Counter] // ... var body: some View { NavigationStack { List { ForEach(counters) { counter in CounterRowItem(counter: counter) } .onDelete(perform: deleteItems) } // ... } } struct IncrementCounterIntent: AppIntent { static var title: LocalizedStringResource = "Increment Counter" @Parameter(title: "Name", optionsProvider: CounterOptionsProvider()) var name: String func perform() async throws -> some IntentResult & ReturnsValue<Int> { let provider = try CounterProvider() guard let counter = try provider.fetchCounters().first(where: { $0.name == name }) else { print("Couldn't find counter with name '\(name)'") return .result(value: 0) } counter.count += 1 try provider.context.save() return .result(value: counter.count) } private final class CounterOptionsProvider: DynamicOptionsProvider { func results() async throws -> [String] { try CounterProvider().fetchCounters().map { $0.name } } } }
Posted
by jhearst.
Last updated
.
Post not yet marked as solved
0 Replies
408 Views
I have a SiriKit type in intent definition which include system field 'identifier' and a custom field id. When I try to migrate to AppIntent, since AppEntity conforms to 'Identifiable' I cannot use 'id' in AppEntity, how can I solve this?
Posted
by eyvallah.
Last updated
.
Post not yet marked as solved
1 Replies
657 Views
I try to make app intent but i'm beginner at swift. so I watched wwdc vedio : Dive into App Intents. - https://developer.apple.com/videos/play/wwdc2022/10032 But i don't know what does 'Navigator' means at the code. Navigator used together with shared, than navigator is used ad singleton? Does anyone have whole sample code along with thins video? struct OpenCurrentlyReading: AppIntent { static var title: LocalizedStringResource = "Open Currently Reading" @MainActor func perform() async throws -> some IntentResult { Navigator.shared.openShelf(.currentlyReading) return .result() } static var openAppWhenRun: Bool = true }
Posted Last updated
.
Post not yet marked as solved
0 Replies
333 Views
Hello, I'm working on the interesting task of blocking settings when I'm using the Parental Control App. Could you advise how to make your Intent visible as Input in IF action?
Posted Last updated
.
Post not yet marked as solved
1 Replies
692 Views
I have implemented a code that answers my question with Siri, but I want to have a continuous conversation like in ChatGPT app. Can't understand documentation properly to do that. import AppIntents @available(iOS 16.0, *) struct MyAppShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: AskQuestionIntent(), phrases: [ "Ask \(.applicationName)", "Ask \(.applicationName) a question" ] ) } } @available(iOS 16, *) struct AskQuestionIntent: AppIntent { static var title: LocalizedStringResource = "Ask question" static var description = IntentDescription("Ask questions directly") @Parameter(title: "Question", requestValueDialog: "What would you like to ask?") var question: String @MainActor func perform() async throws -> some OpensIntent { return .result(opensIntent: self, dialog: IntentDialog(stringLiteral: "some result")) } } Here is How it looks like in ChatGPT: And here is my app: `
Posted
by hotcoder.
Last updated
.
Post not yet marked as solved
0 Replies
916 Views
Hello! I'm trying to donate an Intent to iOS using IntentDonationManager, following the methods described in the documentaion. try await IntentDonationManager.shared.donate(intent: MyIntent()) // succeeded However, I'm not seeing any effect of this action anywhere in the system (iOS 17 and 16). I have debugged it on both the simulator and a physical device, and I have also enabled the "Display Recent Shortcuts" toggle in the developer settings, but I still don't see any relevant suggestions appearing. Similarly, the issue also occurs with the old SiriKit framework, where INInteraction.donate(completion:) doesn't seem to have any observable effect. I recall that in iOS 15, the simulator would immediately present the donated Shortcut action on the lock screen and Spotlight page. However, starting from iOS 16 and continuing to the current iOS 17 beta 1/2, I haven't been able to achieve the same behavior using the same code. Another similar report: https://developer.apple.com/forums/thread/723109 So is there any way to test or verify the results of this donation action?
Posted
by Gong.
Last updated
.
Post not yet marked as solved
0 Replies
594 Views
I have an app intent like the one below. If the intent is run via siri when the phone is locked then the user is asked to unlock their phone but the shortcut is interrupted. Is it possible to delay opening the app until the result dialog is returned? import AppIntents struct MyIntent: AppIntent { static var title: LocalizedStringResource = "MyApp" static var description = IntentDescription("Captures data") static var openAppWhenRun: Bool = true @Parameter(title: "The Data") var theData: String @MainActor func perform() async throws -> some IntentResult { _ = try await RESTClient.postData(theData: theData) return .result(dialog:"Thank you!") //TODO: Now try to open app } }
Posted Last updated
.
Post not yet marked as solved
2 Replies
527 Views
The LanguagePro app creates two shortcut commands by default, as shown in the figure below: Then there is an entry integrated into siri on the app settings page, as shown in the figure below: After clicking to integrate into siri, it will jump to the Shortcut app of the system, and a new shortcut command adding interface will pop up: After clicking the Add button at the bottom, you can see the shortcut command you just added in the shortcut command. View the details of this newly created shortcut command as shown in the figure below: It can be seen that the newly created shortcut command is an integration of the two predefined shortcut commands. I am very curious, what is the coding process of one-click adding to siri on the app setting page, and how to do it. I used the AppIntents framework of iOS16 to build two shortcut commands, corresponding to the above-mentioned "start conversation" and "continue conversation", but I couldn't find a way to complete the construction of "call robot" Please feel free to enlighten me, thank you!
Posted
by lilang2.
Last updated
.
Post not yet marked as solved
3 Replies
1.3k Views
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)") } }
Posted Last updated
.