Shortcuts

RSS for tag

Help users quickly accomplish tasks related to your app with their voice or with a tap with the Shortcuts API.

Posts under Shortcuts tag

107 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

How to change style/design of AppShortcuts in Shortcuts App (tiles vs circle group)
Adding the AppIntent of my app as AppShortcuts to the Shortcuts Apps was easy. This only required an AppShortcutsProvider. However, I am confused how the AppShortcuts are shown in the Shortcuts App. It seems that there are different styles enter image The AppShortcuts of some apps are shown as tiles While shortcuts from other apps are shown as collection of circle icons Some "circle collection" use a default gray background with blue icons Others color or even gradient backgrounds with white icons The only thing I found that might be related to the design is the shortcutTileColor property in the AppShortcutsProvider. However using/changing this property has no effect on how my app's shortcus are shown: On the default gray background / blue icon. Among the different apps on my devices I cannot see any logic which shortcuts are shown as tiles and which as circle icons. Additionally third party apps use colored background or gradients. So there there has to be a way to change this. But how?
0
0
347
Feb ’24
AppIntent: How to find out which Shortcut trigger offers/requires which parameter types
AppIntens can be used as actions when working with Shortcut Automation. iOS offers a bunch of different triggers to start an automation, such as "Time of Day", "Email", "Transaction", etc. Depending on the trigger one can then pass different "Shortcut input" values as parameters to the App Intent. While in many cases the expected type is quite obvious, this is not always the case. An Email type input for example offers Subject, Sender, Recipients, Attachments, Content, Name. Subject will be most likely a String. But is Sender also a String or maybe an IntentPerson? Is Recipients a String (e.g. comma separated) or a collection? Is Attachments a [String], [URL] or [IntentFile]? How to I find out of which types these inputs have? Is there a better way than guessing and trial and error? The documentation provides very little information about supported types in general and I could find nothing about the types used by different triggers. Additionally each "Shortcut input" offers it self as parameter. So the Email type input does not only offer Subject, Sender, etc. as input parameters but also Email. What parameter type does an intent need no accept in order to receive on Email object? Thank you very much for your help.
0
0
365
Feb ’24
How to use and test Wallet Transaction Shortcut in iOS Simulator?
The Shortcuts app offers the possibility to trigger shortcuts/intends when a wallet credit card is used and a new transaction is created. I would like to add transaction details to one of my apps and use such a shortcut for it. Other apps do the exact same thing, so this should not be a problem. Adding a shortcut to my app was not a big deal. However, how can this be tested on simulator? When trying to add a new automatization in the Shortcuts app using a wallet transaction as trigger I cannot finish the setup dialog since the Next button is disabled. I assume this is because no card is configured. When trying to add a card in Wallet I just receive that this was not successful. I have connected the simulator to a Sandbox Apple ID account using a region which supports Apple Pay (US). Using a real account does not solve the problem. Any idea how to get this working? Using real transaction within a store could obviously not be the solution for debugging.
0
0
430
Feb ’24
send http command to iphone
HI... I use iPhone shortcuts to send http commands to my home automation system. I would like to know if it was possible to use them bidirectionally, in the sense that it is my home automation system that sends the http commands to the iPhone, and consequently with the quick commands I can create all the scenarios I want. thank,luca.
0
0
336
Feb ’24
Cannot set app shortcut platter background colour on visionOS
I am trying to set the background colour of my app shortcut platter for the visionOS version using NSAppIconComplementingColorNames but it doesn’t take effect when I check the shortcuts app. I see the built in Music Recognition app has a background colour but I am unable to set one for my app. Please note that this feature is working correctly on iOS. But on visionOS it has no effect and returns a plain background. I am using Xcode 15.3 beta 2 and running the visionOS 1.1 simulator. Sample code from Info.plist: <key>CFBundleIcons</key> <dict> <key>CFBundlePrimaryIcon</key> <dict> <key>NSAppIconComplementingColorNames</key> <array> <string>SMGreen</string> <string>DarkGreen</string> </array> </dict> </dict> Feedback ID: FB13595442
0
0
359
Feb ’24
Dynamic app shortcuts using AppShortcutsProvider and configurable AppIntent
Hello everyone, I want to add preconfigured app shortcuts for my app using an AppShortcutsProvider implementation. I have been following this demo from WWDC22: https://developer.apple.com/wwdc22/10170 All looks pretty straight forward. However, I would like the preconfigured shortcuts to be based on the state of the data in the app: adding one shortcut for every user-entered item in a list. Now, this might be due to the fact that I'm a Swift novice, but I can't figure out how to do that from a AppShortcutsBuilder property as I can't create the AppShortcut instances in a for loop. I have failed to find any resources online on this. I assume I would need the ForEach equivalent of the ViewBuilder? Is anything like that available for AppShortcutsBuilder? I have also stumbled on this: https://developer.apple.com/documentation/sirikit/offering_actions_in_the_shortcuts_app But this solution seems to only work with INIntents rather than AppIntents. Is there a setShortcutSuggestions equivalent for AppIntents that I could call when the contents of my list change?
2
0
788
Jan ’24
Shortcut: Not able to perform() throws --> some ReturnsValue<Image>
Hello Community, I recently started to work on shortcuts with AppIntent and I want to have an image output on my shortcut action. The output of a string is simple and working: func perform() async throws -> some IntentResult & ReturnsValue<String> { let myString : String = "Hello World" return .result(value: myString) I am having trouble to return an image. Ideally I want to load an image from iCloud Drive or from a website and throw image result. I tried func perform() async throws -> some IntentResult & ReturnsValue<Image> { and func perform() async throws -> some IntentResult & ReturnsValue<INFile> { , but was not apple to write a proper code to return .result(value: myImage) . Any help is very welcome and highly appreciated. Have a good week Eric
0
0
295
Jan ’24
iOS 17.2 breaking AppIntents and shortcuts
I have an app that relies heavily on AppIntents and Shortcuts and it seems like the latest iOS update broke those but I can't quite figure out what's the issue. The is that no matter what parameter I pick, when running the shortcut it always uses the defaultResult() Here's an example AppEntity: struct IntentBrokerAppEntity: AppEntity { static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Intent Broker") @Property(title: "Name") var name: String? @Property(title: "Ip") var ip: String? @Property(title: "Port") var port: String? @Property(title: "Username") var username: String? @Property(title: "Password") var password: String? @Property(title: "Tls") var tls: Bool? struct IntentBrokerAppEntityQuery: EntityQuery { func entities(for identifiers: [IntentBrokerAppEntity.ID]) async throws -> [IntentBrokerAppEntity] { return try await suggestedEntities().filter { identifiers.contains($0.id) } } func suggestedEntities() async throws -> [IntentBrokerAppEntity] { let context = PersistenceController.shared.viewContext let brokerService = BrokerService(context: context) return brokerService.getFavorites().map { IntentBrokerAppEntity(broker: $0) } } func defaultResult() async -> IntentBrokerAppEntity? { try? await suggestedEntities().first } } static var defaultQuery = IntentBrokerAppEntityQuery() var id: String // if your identifier is not a String, conform the entity to EntityIdentifierConvertible. var displayString: String var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(displayString)") } ... This used to work perfectly fine before 17.2, but now instead of choosing the entity the user picked it always falls back to defaultEntity(). In the console I get this warning Failed to build EntityIdentifier. IntentBrokerAppEntity is not a registered AppEntity identifier But I'm not sure if that's related. Does anyone have any ideas on what's going on here? Input much appreciated!
3
3
855
Dec ’23
App Intents do not appear in macOS Shortcuts app
I've created a barebones Multiplatform app and added an App Intent and App Shortcut. When running on iOS, I can see my app show up in Shortcuts and use the intent or App Shortcut as normal. On macOS, my app does not appear in the Shortcuts app, neither the App Shortcut nor the intent. Is there additional configuration required to enable Shortcuts / App Intents on macOS? This is the only code I've added to a brand-new Xcode Multiplatform project: import AppIntents struct OpenIntent: AppIntent { static let title: LocalizedStringResource = "Open MacShortcut" static let description: LocalizedStringResource = "Opens the app" /// Launch your app when the system triggers this intent. static let openAppWhenRun: Bool = true /// Define the method that the system calls when it triggers this event. @MainActor func perform() async throws -> some IntentResult { /// Return an empty result since we're opening the app return .result() } } struct MacShortcutShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: OpenIntent(), phrases: [ "Open a session of \(.applicationName)" ], shortTitle: "Open", systemImageName: "arrow.up.circle.fill" ) } }
0
0
454
Dec ’23
How can I pause iOS Shortcut automation programmatically
I want to "pause" an Intent ( iOS Shortcut Automation ) how can I achieve it? Basically we have a small task to execute, whenever we setup an automation for one app, lets say LinkedIn, our app runs and asks the user whether they still want to continue with LinkedIn or whether they don't want to. The automation to open our app when LinkedIn is opened is working fine. What we want to achieve is that once a user taps on "Continue to LinkedIn" it should "pause" the automation this time and open LinkedIn instead of opening our app again.
0
0
502
Dec ’23
Opening an App Conditionally with Swift and App Intents in iOS Shortcuts
I am trying to create a simple app that "blocks" other apps if a certain condition is not met. I am currently using the IOS shortcuts and have set up an automation that opens my app A whenever another app B opens. If the condition is not met i imagine the flow to look like: Open app A. My app B opens instead. I check a box in my app B. I navigate back to app A and it works as expected. If the condition already is met the app A would work as expected from the beginning. What is have tried so far My first attempt involved using an AppIntent and changing the openAppWhenRun programmatically based on the condition. I did however learn pretty quickly that changing the value of openAppWhenRun does not change if the AppIntent actually opens my app. The code for this looked like this where the value of openAppWhenRun is changed in another function. struct BlockerIntent: AppIntent { static let title: LocalizedStringResource = "Blocker App" static let description: LocalizedStringResource = "Blocks an app until condition is met" static var openAppWhenRun: Bool = false @MainActor func perform() async throws -> some IntentResult { return .result() } } Another attempt involved setting openAppWhenRun to false in an outer AppIntent and opening another inner AppIntent if the condition is met. If the condition in my app is met openAppWhenRun is set to true and instead of opening the inner AppIntent an Error is thrown. This functions as expected but there is an error notification showing every time I open the "blocked" app. struct BlockerIntent: AppIntent { static let title: LocalizedStringResource = "Blocker App" static let description: LocalizedStringResource = "Blocks an app until condition is met" static var openAppWhenRun: Bool = false func perform() async throws -> some IntentResult & OpensIntent { if (BlockerIntent.openAppWhenRun) { throw Error.notFound } return .result(opensIntent: OpenBlockerApp()) } enum Error: Swift.Error, CustomLocalizedStringResourceConvertible { case notFound var localizedStringResource: LocalizedStringResource { switch self { case .notFound: return "Ignore this message" } } } } struct OpenBlockerApp: AppIntent { static let title: LocalizedStringResource = "Open Blocker App" static let description: LocalizedStringResource = "Opens Blocker App" static var openAppWhenRun: Bool = true @MainActor func perform() async throws -> some IntentResult { return .result() } } My third attempt look similar to the previous one but instead I used two different inner AppIntents. The only difference between the two were that on had openAppWhenRun = false and the other had openAppWhenRun = true. struct BlockerIntent: AppIntent { static let title: LocalizedStringResource = "Blocker App" static let description: LocalizedStringResource = "Blacks an app until condition is met" static var openAppWhenRun: Bool = false func perform() async throws -> some IntentResult & OpensIntent { if (BlockerIntent.openAppWhenRun) { return .result(opensIntent: DoNotOpenBlockerApp()) } else { return .result(opensIntent: OpenBlockerApp()) } } } Trying this gives me this error: Function declares an opaque return type 'some IntentResult & OpensIntent', but the return statements in its body do not have matching underlying types I have also tried opening the app with a URL link with little to no success often ending up in an infinity loop, I did try the ForegroundContinuableIntent but it did not function as expected since it relies on the users input. Is there any way to do what I am trying to accomplish? I have seen other apps using a similar concept so I feel like this should be possible. Many thanks!
4
5
980
Nov ’23
AppShortcut entities not displayed on spotlight
I have my app that works perfectly fine with app intents and shortcuts in the Shortcut app. I can find my shortcut when I look for my app in spotlight, the only thing that it are not displayed are the suggested entities, even if the param and suggested entities appear on my Shortcut app. I call to the function updateAppShortcutParameters, and I see this error pop up. Could anyone help me understand what I need to do to make it work? Failed to refresh AppShortcut parameters with error: Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)" UserInfo={_LSLine=159, NSUnderlyingError=0x600005417540 {Error Domain=NSOSStatusErrorDomain Code=-10814 "Unable to find this application extension record in the Launch Services database." UserInfo={_LSFunction=_LSPluginFindWithPlatformInfo, _LSLine=679, NSDebugDescription=Unable to find this application extension record in the Launch Services database., SK=MyDemoAppBinary, IS=false}}, _LSFunction=+[LSBundleRecord bundleRecordWithBundleIdentifier:allowPlaceholder:error:]}
0
1
428
Nov ’23
iOS Shortcuts - trying to send message to a phone number from a variable
Hi, I am working on a Shortcut. I collect a phone number in the process and it store in a variable "abc". I succeed in making a phone call when I pass the variable "abc" to the Call action. However I am unable to do the same thing with the Message action. This one only seem to accept a choice from my contacts. Do I understand this correctly? Is there a workaround? Thanks,
0
0
325
Nov ’23