Shortcuts

RSS for tag

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

Shortcuts Documentation

Posts under Shortcuts tag

113 Posts
Sort by:
Post not yet marked as solved
0 Replies
634 Views
I'm writing an application with App Shortcuts support. My task is to write a command that will check whether a certain application is open and runs the command. For example: The user installed a command through my application that responds to the Instagram application The user goes to Instagram My team is starting Question: Is it possible to organize this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
387 Views
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" ) } }
Posted
by Ethan_.
Last updated
.
Post not yet marked as solved
0 Replies
392 Views
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.
Posted
by Dropouts.
Last updated
.
Post not yet marked as solved
0 Replies
350 Views
I would love to be able to add an automation shortcut that adds the sender to spam lists and deletes the message based on a certain word in incoming SMS messages. or blocking numbers based on certain asterix characters. It's the 17th version and these features are still missing.
Posted
by saltug.
Last updated
.
Post not yet marked as solved
3 Replies
786 Views
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!
Posted
by EliasDev.
Last updated
.
Post not yet marked as solved
0 Replies
344 Views
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:]}
Posted
by alexhl09.
Last updated
.
Post not yet marked as solved
0 Replies
281 Views
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,
Posted
by Lanceloz.
Last updated
.
Post not yet marked as solved
0 Replies
457 Views
I've created a shortcut using an AppIntent and AppIntentProvider. When I try to run the shortcut in the shortcuts app it works well, but if I assign that same shortcut to the new Action Button it shows that something is working (icon shows up on the island) but the perform function is never called. Am I missing something? should I add extra configurations for the action button? thanks
Posted Last updated
.
Post not yet marked as solved
0 Replies
263 Views
I have a shortcuts to read out the weather and my schedule for the day after the alarm is off. However I am UNABLE to find any functions to read out the time. Currently, my shortcuts will perform the following: Hello Name It is sunny/raining today, Currently x degrees celsius. You have N schedules today, from x o'clock to y o'clock, you will be meeting abc "read all my schedule" I want it to read the time before telling me the weather. How could I achieve it in the shortcuts? Thanks a lot.
Posted Last updated
.
Post not yet marked as solved
0 Replies
246 Views
Below is the shorcut link: https://www.icloud.com/shortcuts/2aa2e28072f54109a5cdb4fcd17ee74dhttps://www.icloud.com/shortcuts/2aa2e28072f54109a5cdb4fcd17ee74d Basically this shortcut will modify selceted photos. But I don't know which step goes wrong, everytime it will ask too save some numbers to the photo album/libary
Posted
by LJLLJL.
Last updated
.
Post not yet marked as solved
1 Replies
915 Views
I was trying out SiriKit Media Intents and found that with iOS 14, Media Intents can be handled in-app instead of using an extension. Given my current project structure, in-app intent handling suits my purpose better than handling it in an extension. But my question is about how this intent will be handled in a watchOS app? Is in-app Intent Handling supported on watchOS as well (if yes, are there any examples that I can refer to)? If not, can I create an extension for Media Intents and trigger it for watchOS while triggering the in-app handling for iOS alone? Please share if I have missed to read through some documentation / reference that solves this problem.
Posted Last updated
.
Post not yet marked as solved
0 Replies
434 Views
I am trying to import an Automator workflow into the Shortcuts app. I have tried all the methods [suggested by Apple] but all fail with this error: I have copied the workflow to various folders and tried again with the same result. Is this a permissions issue ? I'm on macOS 14.1 Sonoma with Shortcuts 7.0.
Posted
by Crudgle.
Last updated
.
Post not yet marked as solved
0 Replies
458 Views
I am developing an app for my home and I was planning to control my smart home plug with it. So I decided to create two shortcuts: the first one to turn it on, the second one to turn it off. For this, I created an AppIntent and an AppShortcut file: // AppIntent.swift // Runner import AppIntents import Foundation class MerossPostClass{ var request: URLRequest var power_state: String public init(power_state: String) { self.power_state = power_state let url = URL(string: "myurl")! var request = URLRequest(url: url) request.httpMethod = "POST" struct Message: Encodable { let device_type: String let power_state: String let channel: Int } let message = Message( device_type: "mss425f", power_state: power_state, channel: 4 ) let data = try! JSONEncoder().encode(message) request.httpBody = data request.setValue( "application/json", forHTTPHeaderField: "Content-Type" ) self.request = request } public func post(){ let task = URLSession.shared.dataTask(with: self.request) { data, response, error in let statusCode = (response as! HTTPURLResponse).statusCode if statusCode == 200 { print("SUCCESS") } else { print("FAILURE") } } task.resume() } } var activateMeross = MerossPostClass(power_state: "ON") var deactivateMeross = MerossPostClass(power_state: "OFF") @available(iOS 17, *) struct ActivateMagSafeIntent: AppIntent { static let title: LocalizedStringResource = "Activate MagSafe" func perform() async throws -> some IntentResult { activateMeross.post() return .result() } } @available(iOS 17, *) struct DeactivateMagSafeIntent: AppIntent { static let title: LocalizedStringResource = "Deactivate MagSafe" func perform() async throws -> some IntentResult { deactivateMeross.post() return .result() } } // // AppShortcut.swift // Runner import Foundation import AppIntents @available(iOS 17, *) struct ActivateMagSafeShortcuts: AppShortcutsProvider { @AppShortcutsBuilder static var appShortcuts: [AppShortcut] { AppShortcut( intent: ActivateMagSafeIntent(), phrases: ["Activate MagSafe"] ) AppShortcut( intent: DeactivateMagSafeIntent(), phrases: ["Deactivate MagSafe"] ) } } With this Code I can add the shortcuts to the shortcuts app. Problem As long as my device is attached to the debugger, everything is working just fine and I am able to control my smart plug with the shortcuts. But after I detached my phone from the debugger, the shortcuts are only working every second run. After every other run, I get an iOS error message like 'Couldn't Communicate with a helper application' or 'App was terminated unexpectedly'. Is there anybody who has been facing the same issue or has any idea why this is happening? Thanks in advance!
Posted
by alex_hsv.
Last updated
.
Post not yet marked as solved
0 Replies
321 Views
Hi, I have an app that is used by several Shortcuts. In many cases, users download the Shortcut, install the app, and only use the App through the Shortcut, and only through the in-extension Intent. They might never open the app. I've received complaints from users that the app keeps disappearing: apparently, because the app itself is never opened (only the in-extension Intent is), it doesn't count as an actual usage for offloading, and so the app gets offloaded. What can I do?
Posted Last updated
.
Post not yet marked as solved
0 Replies
346 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
0 Replies
312 Views
Hi have shortcut/aut. which writes current date/time in a spreadsheet when I arrive@work. And also when I leave work it write that date/time. Works fine as-long as the iPhone is unlocked. If locked I get err. "Cannot open Numbers while iPhone is locked" Anybody got a clue or even better: solution :-)
Posted Last updated
.
Post not yet marked as solved
1 Replies
1k Views
Hi I am trying to create an Apple shortcut in notes where it creates a note with the current date and then appends text to the note below the date. There is already a shortcut on the Gallery “New Note with Date” which is supposed to do this. However, when running the shortcut, it creates the note with date in the background, then asks for what the note needs to say, then a sheet with all recent notes created pops up and you have to select which note the appended text has to be saved to. My question is, is there a way to create the note with the date and append the text to that note automatically? thanks
Posted
by Darow8.
Last updated
.
Post not yet marked as solved
0 Replies
244 Views
I have very limited knowledge of the shortcut app so I'm hoping someone with more knowledge may be able to help me out. My Issue: My Synology NAS (connected directly via ethernet) randomly disconnects, etc. I'm having to manually connect to it all the time. Adding the volumes onto the login items works while I'm home, but if I'm not I'll get an error since it's not available. What I'm looking for: Creating a shortcut that first checks if the ethernet connection to the NAS is live. Then checks if the drive is already mounted, if it is, do nothing. If it is not mounted, mount the drive. Once I get this shortcut, I should be able to run it automatically using shortery. Here's an image I found online of someone doing exactly this but using WIFI as the network. I'm trying to replicate this using ethernet. https://i.imgur.com/zu24Uy7.jpg
Posted Last updated
.
Post not yet marked as solved
1 Replies
423 Views
I have implemented an AppIntent in my app with the purpose of allowing users to set up an automation within the Shortcuts app that runs based on a boolean value in my app. It works well normally, but I've found that if my app is force quit, the Shortcut no longer works (presumably because it can't fetch the value of the boolean from my app anymore). Does anyone know how to persist this value so that the Shortcut will work regardless of whether my app is open in the background? Here is my implementation of the AppIntent: struct my_automation: AppIntent { static var title: LocalizedStringResource = "Automation Name" var isTrue = UserDefaults.standard.bool(forKey: "myVal") func perform() async throws -> some IntentResult { return .result(value: isTrue) } }
Posted Last updated
.
Post not yet marked as solved
9 Replies
1k Views
Since the iOS 16.4 update on my iPhone 12 Pro I’ve been unable to run shortcuts using the record audio command, if the shortcut was called by Siri. It seems that Siri might be running it twice, as when I set the command to ask for input for its parameters I get the menu twice. When I run it from Siri, the record screen freezes and the seconds don’t count down, but when I run it from Shortcuts it works fine. Has anyone else experienced this, or have any suggestions? Thanks!
Posted Last updated
.