I have started to work on adding Live Activities to my app in watchOS 11. The app already has interactive Live Activities on the phone that works as expected.
I have added a view for the activityFamily: small and it shows up as expected.
My problem is that buttons doesn't work. I use the Intent based button, and on the iPhone Lock Screen they work. On the watch, nothing happens.
Has anyone got this working? Not sure if I'm missing something or if it's a bug.
App Intents
RSS for tagExtend your app’s custom functionality to support system-level services, like Siri and the Shortcuts app.
Posts under App Intents tag
177 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I want to implement AppIntent in my Objective-C framework, because we need to design a fast pass to certain function.
However, I create a struct inherited from AppIntent, and create a projectName-Bridging-Header.h in my framework just like I did in my project. It seems like framework don't work, I can't find it in shortcuts
I want to implement AppIntent in my framework which is created and choose Objective-C as language, but when I new a swift file and implement AppIntent. then import to my project. the AppIntent didn't work. but I can use AppIntent directly in project.
Xcode 15.3 AppIntentsSSUTraining warning: missing the definition of locale # variables.1.definitions
Hello!
I've noticed that adding localizations for AppShortcuts triggers the following warnings in Xcode 15.3:
warning: missing the definition of zh-Hans # variables.1.definitions
warning: missing the definition of zh-Hans # variables.2.definitions
This occurs with both legacy strings files and String Catalogs.
Example project: https://github.com/gongzhang/AppShortcutsLocalizationWarningExample
After watching the What's new in App Intents session I'm attempting to create an intent conforming to URLRepresentableIntent. The video states that so long as my AppEntity conforms to URLRepresentableEntity I should not have to provide a perform method . My application will be launched automatically and passed the appropriate URL.
This seems to work in that my application is launched and is passed a URL, but the URL is in the form: FeatureEntity/{id}.
Am I missing something, or is there a trick that enables it to pass along the URL specified in the AppEntity itself?
struct MyExampleIntent: OpenIntent, URLRepresentableIntent {
static let title: LocalizedStringResource = "Open Feature"
static var parameterSummary: some ParameterSummary {
Summary("Open \(\.$target)")
}
@Parameter(title: "My feature", description: "The feature to open.")
var target: FeatureEntity
}
struct FeatureEntity: AppEntity {
// ...
}
extension FeatureEntity: URLRepresentableEntity {
static var urlRepresentation: URLRepresentation {
"https://myurl.com/\(.id)"
}
}
Here is the screenshot of the error screen.
If someone has any idea about this or implementation of in-app search please guide me. thanks
While Implementing Wallet Intent Extension, and after verification
The only message i get is
Cannot Add Card
There are no available cards to add.
Any help here is appreciated.
In previous years it seems there were limitations about where AppIntent types could live in your code base for them to be surfaced up to the Shortcuts app. Specifically, they needed to be in the top level app or extension target.
However, WWDC24's What's new in App Intents talks about "Framework Improvements" and has a slide that implies that AppEntity, AppEnum, AND AppIntent types can live in a framework.
Is this actually the case? I can see the Metadata.appintents in the build products of my framework, and my intent is included in the JSON, but these intents never make it into the Shortcuts app when I install an app that consumes the framework. I'm testing this with Xcode 16b1 in a iOS 18 simulator.
We have an existing app in which we have implemented AppShortcuts. The snippet view works fine in iOS 17 while in iOS18 beta, it doesn't able to fetch color from xcassets. If we use system colours or UIColor it's working fine.
Not working
Color("progressColor")
Working
Color(uiColor: UIColor(named: "progressColor")!)
Color.red
Color(hex: "3881d3") // Note: We created Color extension to generate color from hex string.
Using App Shortcuts with app intents, Siri only responds to the first shortcut defined in the app shortcut below.
struct MementoShortcuts: AppShortcutsProvider {
u/AppShortcutsBuilder
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: SaveLinkIntent(),
phrases: ["Add a link to \(.applicationName)", "Add \(\.$url) to \(.applicationName)", "Make a new link in \(.applicationName)", "Create a new link in \(.applicationName) from \(\.$url)"],
shortTitle: "Add Link",
systemImageName: "link.badge.plus"
)
AppShortcut(
intent: LinkViewedIntent(),
phrases: [
"Mark a link I saved in \(.applicationName) as viewed",
"Mark \(\.$link) as viewed in \(.applicationName)",
"Set link in \(.applicationName) to viewed",
"Change status of \(\.$link) to viewed in \(.applicationName)",
],
shortTitle: "Mark Link as Viewed",
systemImageName: "book"
)
}
}
I have tried switching the order and she always uses the one that comes first. Both show up in the shortcuts app as an app shortcut, but only one shortcut is recognized by Siri even if I say the other one's phrase.
When in Safari, you can say something like, "Siri, text this link to mom" or "Siri, save this link to reminders" and it will do it with the currently viewed link. Shortcuts also has a "Get what's on screen" action that can be added. How do I expose the user's current context to my App Intent?
When I start a workout in my app, the system shows a Live Activity in the Smart Stack like in the picture. My app opens if I tap on it, but the pause and resume buttons doesn't do anything.
I have implemented the PauseWorkoutIntent and ResumeWorkoutIntent which works with the Action Button. I guessed that these would be used from this Live Activity as well, but it seems like not.
Has anyone successfully integrated with this? I haven't seen it documented anywhere, although I think it was already included in watchOS 10.
This is also shown when using the built in workout app and for that the buttons work as expected.
When using App Intents, I can edit already existing SwiftData items, but I cannot insert new ones. Below are the two app intents I've used, both function in their entirety other than the model context insertion at the end of the second one.
struct LinkViewedIntent: AppIntent {
static var title: LocalizedStringResource = "Mark Link Viewed"
@Parameter(title: "Link")
var link: LinkEntity?
init(link: Link) {
self.link = LinkEntity(link: link)
}
init() {}
func perform() async throws -> some IntentResult & ProvidesDialog {
let entities = try await LinkEntityQuery().suggestedEntities().filter({$0.viewed == false})
guard !entities.isEmpty else {
return .result(dialog: "There are no unviewed links to mark.")
}
var enteredLink: LinkEntity
if let link = link {
enteredLink = link
} else {
enteredLink = try await $link.requestDisambiguation(
among: LinkEntityQuery().suggestedEntities(),
dialog: "Which link would you like to mark viewed?"
)
}
let context = ModelContext(ConfigureModelContainer())
let links = try? context.fetch(FetchDescriptor<Link>())
guard let link = links?.filter({ $0.id == enteredLink.id }).first else {
return .result(dialog: "An Error Occured")
}
if link.viewed == true {
return .result(dialog: "Link is already viewed")
}
link.viewed = true
try context.save()
return .result(dialog: "Okay, \(enteredLink.name ?? enteredLink.link) has been marked as viewed.")
}
static var parameterSummary: some ParameterSummary {
Summary("Mark \(\.$link) as viewed.")
}
}
struct SaveLinkIntent: AppIntent {
static var title: LocalizedStringResource = "Save Link"
@Parameter(title: "URL")
var url: URL?
func perform() async throws -> some IntentResult & ProvidesDialog {
let modelContext = ModelContext(ConfigureModelContainer())
var fullurl: URL
if let url = url {
fullurl = url
} else {
fullurl = try await $url.requestValue()
}
print(fullurl.absoluteString)
guard let link = await makeLink(address: fullurl.absoluteString) else {
return .result(dialog: "")
}
modelContext.insert(link)
return .result(dialog: "I've added \(link.metadata?.title ?? link.address) to Memento")
}
}
I'm experiencing an issue with microphone recording in my app when launched from a Shortcut. The app works correctly when launched directly, but launching it through the Shortcut results in the "Session activation failed" error (code 561015905).
Here's what I've done so far:
My app has microphone permission granted.
The startRecording function sets the audio session category to .playAndRecord.
I've implemented error handling within startRecording to catch the error code.
The Shortcut workflow includes an action to launch the app (no explicit microphone permission request within the Shortcut).
xcode version - 15.2
iphone ios version - 17.4.1
My App has several resources that I'd like to spring open through App Intents. For example a series of Dictionaries. These resources however in the app are behind a log in (for security) and are entitlements that are purchased. They may own 4 of 7 dictionaries.
If I want to have an intent that says, "Open Dictionary: (Dict Name)" how do I best handle situations where the user may no longer be logged in or have the entitlement for that specific dictionary?
Thanks
I have a Shortcuts action via an App Intent that I want only for active subscribers to use.
I have a shared class that handles all the subcription related things. But for some reason my code only works if the app is active in the background. Once the app is quitted and the user performs the Shortcut, the not subscribed error is thrown – even though the user is subscribed.
How can I ensure that my subscription check is done correctly, if the app isn’t open in the background?
My Code
App Intent excerpt:
@MainActor
func perform() async throws -> some IntentResult & ReturnsValue<MeterIntentEntity> {
// Validate that the user is subscribed.
// Cancels action with error message if not subscribed.
if SubscriptionManager.shared.userIsSubscribed == false {
throw IntentError.notSubscribed
}
// More Code …
// Finish and pass created value as result.
return .result(value: something)
}
Subscription Manager excerpt:
class SubscriptionManager: ObservableObject {
// A singleton for our entire app to use
static let shared = SubscriptionManager()
let productIds = ["my_sub1", "my_sub2"]
@Published private(set) var availableSubscriptions: [Product]
@Published private(set) var purchasedSubscriptions: [Product] = []
public var userIsSubscribed: Bool {
return !self.purchasedSubscriptions.isEmpty
}
init() {
// Initialize empty products, and then do a product request asynchronously to fill them in.
availableSubscriptions = []
Task {
await updatePurchasedProducts()
}
}
@MainActor
func updatePurchasedProducts() async {
for await result in Transaction.currentEntitlements {
do {
let transaction = try checkVerified(result)
if let subscription = availableSubscriptions.first(where: { $0.id == transaction.productID }) {
purchasedSubscriptions.append(subscription)
}
} catch {
Logger.subscription.error("Error loading users user's purchased products.")
}
}
}
I would be great if the watchOS can adopt some of the new App Intents for the Action Button on iOS.
On Apple Watch Ultra this is still limited on workout related Intents (However system apps like flash light can do more).
See als this FB:
FB11699104 (opened in 2022)
Best regards
Arno
I have an app that currently supports as low as iOS 16. I'd like to add some app intents to it that allow customization using the WidgetConfigurationIntent API that's only available on iOS 17 and later. Is there a way to build an intent (or other kind of app extension) that requires a higher OS version than my main app's deployment target, and only surface it for those OS versions?
iOS 18 adds a specific macro for exposing your search app intent, app entities, etc, to siri but how are you meant to add it to your existing objects without removing it entirely from < iOS 18 users?
For example, i get the following error:
AssistantIntent(schema:) is only available in iOS 18 or newer. Add @available attribute to enclosing struct.
I don't want to do that since i still want to support iOS 17 users with my existing shortcuts. Do i need to duplicate my entire shortcuts model to add the new macro?
I want to add shortcut and Siri support using the new AppIntents framework. Running my intent using shortcuts or from spotlight works fine, as the touch based UI for the disambiguation is shown. However, when I ask Siri to perform this action, she gets into a loop of asking me the question to set the parameter.
My AppIntent is implemented as following:
struct StartSessionIntent: AppIntent {
static var title: LocalizedStringResource = "start_recording"
@Parameter(title: "activity", requestValueDialog: IntentDialog("which_activity"))
var activity: ActivityEntity
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog {
let activityToSelect: ActivityEntity = self.activity
guard let selectedActivity = Activity[activityToSelect.name] else {
return .result(dialog: "activity_not_found")
}
...
return .result(dialog: "recording_started \(selectedActivity.name.localized())")
}
}
The ActivityEntity is implemented like this:
struct ActivityEntity: AppEntity {
static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "activity")
typealias DefaultQuery = MobilityActivityQuery
static var defaultQuery: MobilityActivityQuery = MobilityActivityQuery()
var id: String
var name: String
var icon: String
var displayRepresentation: DisplayRepresentation {
DisplayRepresentation(title: "\(self.name.localized())", image: .init(systemName: self.icon))
}
}
struct MobilityActivityQuery: EntityQuery {
func entities(for identifiers: [String]) async throws -> [ActivityEntity] {
Activity.all()?.compactMap({ activity in
identifiers.contains(where: { $0 == activity.name }) ? ActivityEntity(id: activity.name, name: activity.name, icon: activity.icon) : nil
}) ?? []
}
func suggestedEntities() async throws -> [ActivityEntity] {
Activity.all()?.compactMap({ activity in
ActivityEntity(id: activity.name, name: activity.name, icon: activity.icon)
}) ?? []
}
}
Has anyone an idea what might be causing this and how I can fix this behavior? Thanks in advance