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

106 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

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
0
1
557
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
305
Nov ’23
Supporting In-App SiriKit Media Intents in watchOS
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.
1
0
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
547
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
371
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
420
Oct ’23
Append Note in Shortcuts
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
1
0
1.1k
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
276
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
502
Oct ’23
iOS shortcut hangs with record audio if called by Siri in 16.4
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!
9
2
1.1k
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
326
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
779
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
357
Oct ’23
AppIntentsPackage protocol with SPM package not working
Hi, I am trying to integrate the new AppIntentsPackage protocol into my application. Especially what I want to do is to create a dedicate SPM package which holds all my app intents and then share that with my widget extension for Widget intents as well as the main iOS app for powering an AppShortcutProvider. Unfortunately I run into an issue here. I have the following explanatory setup: SPM package called ProjectAppIntents iOS target My AppIntents SPM package //Package: ProjectAppIntents public struct TestAppIntent: AppIntent { public static var title: LocalizedStringResource = "TestAppIntent" @Parameter(title: "Parameter1", optionsProvider: ParameterOptionProvider()) public var parameter: String public init(parameter: String) { self.parameter = parameter } public init() { } public func perform() async throws -> some IntentResult & ReturnsValue { .result(value: 5) } } struct ParameterOptionProvider: DynamicOptionsProvider { func results() async throws -> [String] { return ["Hello", "World"] } } public struct ProjectAppIntentsPackage: AppIntentsPackage { } My iOS app // Target: iOS import ProjectAppIntents struct ProjectApp: App { var body: some Scene { WindowGroup { ContentView() } } } extension ProjectApp: AppIntentsPackage { static var includedPackages: [AppIntentsPackage.Type] = [ ProjectAppIntentsPackage.self ] } struct ProjectShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: TestAppIntent(), phrases: ["Start a \(.applicationName)"], shortTitle: "Hello World", systemImageName: "house" ) } } When I now try to compile my app, I get the following build error: 2023-06-25 09:53:47.853 appintentsnltrainingprocessor[44848:2059163] Parsing options for appintentsnltrainingprocessor 2023-06-25 09:53:47.854 appintentsnltrainingprocessor[44848:2059163] Starting AppIntents SSU YAML Generation 2023-06-25 09:53:47.868 appintentsnltrainingprocessor[44848:2059163] error: The action TestAppIntent referenced in App Shortcut does not exist Command AppIntentsSSUTraining failed with a nonzero exit code So for me it seems like the compiler cannot find the AppIntent defined in an SPM package. Am I doing something wrong here or does the AppIntentsPackage protocol not work with SPM packages ? Thanks a lot for helping !
11
3
2.6k
Oct ’23