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

108 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

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
451
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
330
Nov ’23
Shortcut not working on Action Button
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
2
2
575
Nov ’23
Shortcuts - how to make it read current time?
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.
0
0
309
Nov ’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
1k
Nov ’23
Shortcuts of developed app are not working properly
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!
0
0
560
Oct ’23
Offloading issues, for an App that is mostly used for Shortcuts
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?
0
0
384
Oct ’23
App Intents get "App" as a parameter (SwifUI with IOS 17.0)
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.
0
0
439
Oct ’23
Seeking help with shortcut
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
0
0
284
Oct ’23
Shortcut URL
Hello / Bonjour, (English version follows) Je souhaite réaliser une action particulière et je me tourne vers la communauté Apple pour savoir si c'est faisable. Voici ma demande : Je souhaite créer une action qui, lorsque vous la cliquez, vous demande de saisir la registration d'un avion que je souhaite observer (http://www.airframes.org/reg/{registration à compléter ici}. Vous pouvez le saisir dans la petite fenêtre Shortcut qui s'ouvre à l'écran, comme illustré dans cette image : Fenêtre Shortcut : (Donc par exemple, je saisis 'fhtya' dans la fenêtre qui s'ouvre.) Une fois que j'ai saisi le numéro d'enregistrement de l'avion (par exemple, "fhtya"), le raccourci devrait me renvoyer le contenu de la page correspondante avec les informations de l'avion, telles que : Avion : Airbus A350 Numéro d'enregistrement : F-HTYA Compagnie : Air France J'espère que ma demande est claire. Merci beaucoup pour votre aide. Barnabé Hello, I'd like to do something specific and I'm looking to the Apple community to see if it's possible. Here is my request: I want to create an action which, when you click it, asks you to enter the registration number of an aircraft I want to observe (http://www.airframes.org/reg/{registration to be completed here}. You can enter this in the small Shortcut window that opens on the screen, as shown in this image: Shortcut window: (So, for example, I type 'fhtya' in the window that opens). Once I've entered the aircraft registration number (for example, "fhtya"), the shortcut should return the contents of the corresponding page with the aircraft information, such as : Aircraft: Airbus A350 Registration number: F-HTYA Airline: Air France I hope my request is clear. Thank you very much for your help. Barnabé
0
0
330
Oct ’23
Action Button on Apple Watch Ultra 2 calls shortcut twice
Has anyone else seen this issue? When the Action Button on an Apple Watch Ultra 2 is connected to a Shortcut, it seems to run the shortcut twice. I'm on watchOS 10.0.2. A user of an app I built reported the issue, which is how I knew about it in the first place. I'm wondering if it's an issue on my watch specifically, or if many other people are seeing the same thing. I replicated the issue using a fresh project, and it only seems to happen when the shortcut responds with dialog. Does anyone know why this is happening and how to fix it? The shortcut with a dialog response works fine everywhere else, and only exhibits this behavior when run with the Action Button. Here is the full code with instructions to replicate the issue, so I'm curious if other people see the same thing: // When running a shortcut that returns dialog // with the Apple Watch Ultra Action Button, // the shortcut runs twice. // Create a new iOS project and add this: import AppIntents // AppIntent struct LogEventNow: AppIntent { static var title: LocalizedStringResource = "Log an Event" @MainActor func perform() async throws // -> some IntentResult // When just returning a successful result with .result(), // the shortcut only runs once as expected // Add ProvidesDialog to be able to return .result(dialog:) -> some IntentResult & ProvidesDialog { let loggedDate = Date() let formattedLoggedDate = loggedDate.formatted(date: .omitted, time: .complete) // Print the time of the event that was logged print(formattedLoggedDate) // This gives the expected result // Shortcut runs once, and prints one time to the console // return .result() // This gives unexpected result // Shortcut seems to run twice // and prints two date a 1–2 seconds apart return .result(dialog: "Successfully logged.") } } // AppShortcut // This makes it show up in the Shortcuts app struct EventShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: LogEventNow(), phrases: ["Log in \(.applicationName)"], shortTitle: "Log Event Now", systemImageName: "calendar" ) } } // Steps to reproduce the issue: // - Long press the AppShortcut in Shortcuts app // - Tap "Add to Shortcut" // - Tap the "i" at the bottom // - Turn on "Show on Apple Watch" toggle // - Open the Watch app on iPhone // - Tap "Action Button" // - Under "Action" choose "Shortcut" // - Select the Shortcut that was created in the Shortcuts app // - Push the Action Button and observe two dates printed to the console // Sometimes I'm also seeing "Remote execution timed out" on Apple Watch a minute or so after the shortcut has run, but only when leaving the Shortcuts app open after it runs from the Action button.
1
0
799
Oct ’23
Unable to advertise app shortcuts
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.
0
0
374
Oct ’23
Persist AppIntent after Force Quit?
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) } }
1
0
529
Oct ’23
if App is open condition for shortcuts
Hello. In personal automations we have a condition "when app is open/closed". Can i use similar condition for public shortcuts? I tried to do it using "if" statement, but it hasn't "open/closed app" condition in params. Or maybe i didnt find it? For example, my case: When specified app is opened (e.g. LinkedIn), i need to set a VPN connection and when app closes VPN disconnecting Thanks for help and have a good day to all
0
0
596
Sep ’23
App Intent incorrectly parses milliliters as megaliters in the en-GB environment
Hello, I just discovered that on iOS 17.0 (release), if Measurement<UnitVolume> is used in App Intent, the system will incorrectly parse mL (milliliters) as megaliters. They differ by 9 orders of magnitude. This issue only occurs in the English + United Kingdom regional format. Sample code: https://github.com/gongzhang/AppIntentUnitVolumeBugUnderEnGB Screen recording: https://youtu.be/rMMAHOFpPXs
1
0
427
Sep ’23
.md support broken on MacOS
After I uninstalled Xcode and its CLI tools from my MacBook (Intel based, Ventura 13.5.2) the operating system seems to have forgotten how to handle Markdown files. I can still open them using VSCode or TextEdit but when I preview them using space they just show the file icon. My major issue with this is that I am using shortcuts to interact with them. They also stopped working on my MacBook exclusively. On both iPad and iPhone they still work. I appreciate any ideas on how to resolve this issue.
1
0
694
Sep ’23
Unable to call code inside App Intent Extension like updateAppShortcutParameters() - Linking error
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
0
0
529
Sep ’23