I am trying to create a shortcut following "Implement App Shortcuts With App Intents" talk from WWDC2022.
The below is my MWE. In a standalone app, this can be extended and behave like the video. Adding this code to my main app, makes the shortcut show up within the Shortcuts app, but if I click on it, it pops up an alert saying
Error Domain=LNActionForAutoShortcutPhraseFetchError Code=1 "Couldn't find AppShortcutsProvider" UserInfo={NSLocalizedDescription=Couldn't find AppShortcutsProvider}
My main app has several targets, so I suppose I need to establish which one is the shortcuts provider, but I cannot find any reference to how to do this in the documents.
Via Siri, the shortcut command is not recognised at all.
import AppIntents
import SwiftUI
struct DoSomething: AppIntent {
static var title: LocalizedStringResource = "Do something"
func perform() async throws -> some IntentResult {
return .result()
}
static var openAppWhenRun: Bool = false
}
struct MyShortcuts: AppShortcutsProvider {
@AppShortcutsBuilder
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: DoSomething(),
phrases: ["Do Something in \(.applicationName)"],
systemImageName: "books.vertical.fill"
)
}
}
Shortcuts
RSS for tagHelp 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
I would like to perform certain actions when I receive messages from the Bank.
There is an option in shortcuts to run the automation when receiving messages from certain contacts.
The problem is that I can't store the bank in my contacts as they do not have a phone number or something.
I want to achieve this goal in any possible way.
What I have tried is to store - their contact - in my contacts so that I will be able to set up the automation.
When I tried to store iPhone just shows me the prompt to create a contact with NO values whatsoever. SO it will just be an empty contact.
Any ideas how on how I can achieve that?
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.
Hello
I have a shortcut that, among other things, triggers airplane mode on. This however only works on the device i activate the shortcut on. So if i activate it from my watch, my watch goes into airplane mode, but not my phone. Same the other way around. If i turn on airplane mode manually (control center) it does mirror my other devices.
I would like the shortcut to work the same way as manual activation.
Can anyone help me with that?
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
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
I am trying to implement App Shortcuts for my app. I want to implement the same as Books. I am trying to do 2 things.
I want to set a custom image for each App Shortcut.
I want to set custom color for the Shortcuts background like orange in the Books App Shortcuts.
I am trying to implement in iOS 16.
Kindly share your ideas.
If at all possible, kindly share a snippet
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.
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
My concern is that I am not able to run the app specific shortcut (which is available to develop on iOS 16/ iOS 17) on any other language except English using Siri. I’m facing the issue when I say : “Siri do A” and Siri founds the similar shortcut in the iOS (not in the my app) and runs it.
on English everything works well, but on Russian ( for example) I am facing the described above issue.
How can I fix it?
Hi,
I will creat this autmation:
When this number calls then answers automatically, press 1 and hang up
Is this possible with the Shortcut application? Can anyone help me.
I want when the intercom in my building calls to answer and open automatically
Thanks
As you can see in the following screenshot the „Water“ selection is an AppEnum which gets a nicely tinted SF Symbol. On the other hand, the „My Home“ is an AppEntity which also uses an SF Symbol, but doesn’t get the blue tint. Why?
Now my question is, how can I force the tint on the AppEntity as well?
I’ve defined it the following way:
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(
title: "\(title)",
image: .init(systemName: "house", isTemplate: true)
)
}
But even adding the isTemplate doesn’t work here …
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?
Hi.
I switched my app from the old (<2018) Home Screen static Quick Actions implementation to the new one using the Info.plist.
Old implementation:
let shortcut1 = UIApplicationShortcutItem(
type: ShortcutType.doStuff1.rawValue,
localizedTitle: "title",
localizedSubtitle: nil,
icon: UIApplicationShortcutIcon(systemImageName: "moon"),
userInfo: nil)
application.shortcutItems = [shortcut1]
New implementation using Info.plist:
https://developer.apple.com/documentation/uikit/menus_and_shortcuts/add_home_screen_quick_actions
Now ... the new shortcut items from the Info.plist appear correctly in the new app, however shortcut1 from the old version is also still there. The new code has no traces of the old code anymore!
Why is that?
How can I get rid of it without removing the app and reinstalling it (which would work)?
Thanks,
I’m implementing App Shortcuts in my iOS app to allow you to add and find plants. In attempt to get a “Find Plants” shortcut, I created a query that conforms to EnumerableEntityQuery and set that as the defaultQuery in my PlantAppEntity. I have the typeDisplayRepresentation set to TypeDisplayRepresentation(name: "Plant", numericFormat: "\(placeholder: .int) plants"). I added a Localizable.stringsdict to the app target, added Plant and %lld plants as the header comments shows, then clicked Localize so now English is selected in the Localization section. But when I run the app then open Shortcuts and tap my app, there’s a Find Plant shortcut, but I expected it to be titled Find Plants. When I tap the info button it shows “plant” instead of “plants” in every parameter description. When you add that action to a shortcut the placeholder is All Plant, unlike similar shortcuts from Reminders and Contacts that say “All Reminders” and “All Contacts”. The action is working properly as it returns an array of plants, the only issue is it’s using the singular form of plant in places it should be plural. Have I done something wrong, am I missing anything, or is this a bug? (FB12908309)
Xcode 15 beta 6 :
Xcode is looking for "${applicationName}" in the strings file keys instead of the value only.
(it was working on Xcode 14)
error : Invalid Utterance. Every App Shortcut utterance should have one '${applicationName}' in it.
I have an app that has a different target for each platform. And each one has a different identifier.
How to make same shortcut actions (AppIntent) visible on all the platforms, so one shortcut can be used everywhere?
I would like to know on a mdm managed supervised device, how to force use Safari if a user has non-safari browser set as default.
can enforcing safari for a domain or web clip be done?
even shortcuts now, when using safari it opens whatever is set as default browser. Ironically if same simple shortcut of open URL with Chrome is created it opens with Chrome, regardless if default browser is set to firefox for example
this default browser setting is great for personal use but cause issues now for corporate use for me
anybody else figure this out? Also affects certificates for our managed devices
In iOS 17 when you search Spotlight for Notes you can see it has an App Shortcut titled New Note that simply opens the Notes app and starts composing a new note. When you open the Shortcuts app, create a new shortcut, search for and tap Notes, notice the New Note action is ONLY included at the top - it's not in the list of actions underneath. There is another intent in the list titled Create Note which will create a new note using the content you specify without opening the Notes app.
I want to achieve this same thing in my app - an App Shortcut to open the app and start creating a new item, and a shortcut action to create a new item without opening the app. How can this be done?
So far I have created two AppIntents, NewItem and CreateItem. My AppShortcutsProvider only includes NewItem. This works great when searching for my app in Spotlight. But when I open Shortcuts and go to add an action from my app to a shortcut, it includes Add Item at the top as an App Shortcut but also in the actions list underneath. Create Item is included in the list as well which is confusing. I don't want Add Item to be an available action because it's fairly useless to open the app and start creating an item, instead they should use Create Item to create an item in the background.
Do I need to instead create a single shortcut that behaves differently in Spotlight vs Shortcuts, is that possible?
struct MeditationShortcuts: AppShortcutsProvider
{
AppShortcut(
intent: OCRIntent(),
phrases: [AppShortcutPhrase<OCRIntent>.init("OCR识别\(AppShortcutPhraseToken.applicationName)")],
shortTitle: "文字识别",
systemImageName: "checklist"
)
}
static var shortcutTileColor: ShortcutTileColor {
return .orange
}
}
Why packaging shortcut instructions in the above way will not be displayed in the shortcut instruction app?
Defining a phrase in literal terms will show, for example
struct MeditationShortcuts: AppShortcutsProvider
{
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: OCRIntent(),
phrases: ["OCR识别\(.applicationName)"],
shortTitle: "文字识别",
systemImageName: "checklist"
)
}
static var shortcutTileColor: ShortcutTileColor {
return .orange
}
}