We were using custom UI with inbuilt sendPayment intent. Before 17.0 version, the final handle function would call the custom UI configureView method to show final success UI. However, post 17.0 this is not working the final handle function is not invoking configureView of UIExtension. Please suggest if we have any fix for this issue.
Intents
RSS for tagShare intents from within an app to drive system intelligence and show the app's actions in the Shortcuts app.
Posts under Intents tag
90 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have an app intent that returns a file from inside the Sandbox.
With iOS 18 RC, the call to INFile results in the file being deleted, instead of the file being returned.
intentResponse.file = INFile(fileURL: fileURL, filename: fileName, typeIdentifier: nil)
This seems to happen if the file was created by an earlier Shortcut action that calls FileManager().copyItem(), but not for files created by other means.
I haven't found a reference in the developer documentation about INFile resulting in the file being deleted.
I can block FileManager() from deleting the file by setting its immutable attributes to true, but that prevents me from removing it later.
iOS 17.6.1 WatchOS 10.6.1
WatchAPP安装完毕之后,未登录,可以进入执行,提示 “未登录”
WatchAPP登录后,提示 “Apple Watch无法运行快捷指令,与App通信出现问题”
To support AppIntent in our app, we plan to follow the same approach as the “Get Details of Reminders” Shortcut Action in the Reminders app, as recommended in this WWDC session (https://developer.apple.com/wwdc24/10176?time=166). The goal is to allow querying all properties of an entity—referred to as “Node” in our app—using a single, configurable intent. For instance, we want one intent that can query properties like “Title,” “Background Color,” and “Font Name” for a specific node.
However, since the returned properties have varying data types, this setup requires flexible return types in the perform implementation of our “Get Details” intent. The challenge is that the AppIntent protocol mandates the use ReturnsValue one associated type as the result of perform. For example, we can use ReturnsValue<String> to retrieve the “Title” property, but this would restrict us from using ReturnsValue<Color> for the “Background Color” property.
What’s the best approach for implementing an Intent where the return types vary based on the input parameters provided?
how to register more than 10 shortcuts
使用APPIntent 的AppShortcutsProvider方式,最多只能添加10个AppShortcut,超过10个,代码编译就会报错
struct MeditationShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: StartMeditationIntent(),
phrases: [
"Start a (.applicationName)",
"Begin (.applicationName)",
"Meditate with (.applicationName)",
"Start a (.$session) session with (.applicationName)",
"Begin a (.$session) session with (.applicationName)",
"Meditate on (.$session) with (.applicationName)"
]
)
}
}
如何能做到像特斯拉APP一样
After building my app with Xcode 16 beta 6 I'm getting this warning in my AppIntents.
Encountered a non-optional type for parameter: computer. Conformance to the following AppIntent protocols requires all parameter types to be optional: AppIntents.WidgetConfigurationIntent, AppIntents.ControlConfigurationIntent
The intent looks something like this
struct WakeUp: AppIntent, WidgetConfigurationIntent, PredictableIntent {
@Parameter(title: "intent.param.computer", requestValueDialog:"intent.param.request_dialog.computer")
var computer: ComputerEntity
init(computer: ComputerEntity) {
self.computer = computer
}
init() {
}
public static var parameterSummary: some ParameterSummary {
Summary("Wake Up \(\.$computer)")
}
static var predictionConfiguration: some IntentPredictionConfiguration {
IntentPrediction(parameters: (\.$computer)) { computer in
DisplayRepresentation(
title: "Wake Up \(computer)"
)
}
}
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog {
}
}
According to the docs though specifying optional is how we say if the value is required or not. https://developer.apple.com/documentation/appintents/adding-parameters-to-an-app-intent#Make-a-parameter-optional-or-required
So is this warning accurate? If so, how do I specify that a parameter is required by the intent now?
Async image is not loading in app intent's view.
Image is just not loading without any error
I am trying to implement URLRepresentableEntity on my AppEntity
I am following along with the WWDC video here
All compiles fine when I use the ID as in the video:
extension SceneEntity: URLRepresentableEntity {
static var urlRepresentation: URLRepresentation {
"https://example.com/scene/\(.id)"
}
}
but my URLs need to use a different property on the Entity. The WWDC video clearly states: "Notice that I'm using the entity’s identifier as an interpolated value. You can use an entity’s ID or any of its properties with the @Property attribute as interpolations in the URL string."
So I annotated my entity with the @Property attribute and expected that to work but it doesn't compile.
struct SceneEntity: AppEntity {
let id: UUID
@Property(title: "Slug") var slug: String
}
extension SceneEntity: URLRepresentableEntity {
static var urlRepresentation: URLRepresentation {
"https://example.com/scene/\(.slug)"
}
}
Type 'EntityURLRepresentation.StringInterpolation.Token' has no member 'slug'
How can I use this API with a property that is not the ID?
The action “bla bla” could not run because of an internal error on specific mobile only
I have tried updating shortcuts app and restart my phone but nothing works
We are working with an app that uses the INPlayMediaIntent to allow users to select and play music using Siri.
In building out this feature, we have noticed that when selecting playlists to play, Siri will consistently leave out information from the intent that we are use to resolve the media to play in the app.
It seems that there is generally no rhyme or reason as to why some information is left out.
Walking through a couple test cases, here is the phrase and corresponding mediaSearch that we receive when testing:
"Hey Siri, play the playlist happy songs in the app " (this is a working example)
▿ Optional<INMediaSearch>
- some : <INMediaSearch: 0x114050780> {
reference = 0;
mediaType = 5;
sortOrder = 0;
albumName = <null>;
mediaName = happy songs;
genreNames = (
);
artistName = <null>;
moodNames = (
);
releaseDate = <null>;
mediaIdentifier = <null>;
}
"Hey Siri, play the playlist my favorites in the app " (this fails with a null mediaName)
▿ Optional<INMediaSearch>
- some : <INMediaSearch: 0x114050600> {
reference = 0;
mediaType = 5;
sortOrder = 0;
albumName = <null>;
mediaName = <null>;
genreNames = (
);
artistName = <null>;
moodNames = (
);
releaseDate = <null>;
mediaIdentifier = <null>;
}
"Hey Siri, play the playlist working out playlist in the app " (this fails as the term "playlist" is excluded)
▿ Optional<INMediaSearch>
- some : <INMediaSearch: 0x114050ae0> {
reference = 0;
mediaType = 5;
sortOrder = 0;
albumName = <null>;
mediaName = working out;
genreNames = (
);
artistName = <null>;
moodNames = (
);
releaseDate = <null>;
mediaIdentifier = <null>;
}
"Hey Siri, play the playlist recently added in the app " (this fails with a null mediaName)
▿ Optional<INMediaSearch>
- some : <INMediaSearch: 0x1140507e0> {
reference = 0;
mediaType = 5;
sortOrder = 0;
albumName = <null>;
mediaName = <null>;
genreNames = (
);
artistName = <null>;
moodNames = (
);
releaseDate = <null>;
mediaIdentifier = <null>;
}
Based on the above, Siri seems to ignore playlists named "Recently Added", "My Favorites", and playlists that have the word "playlist" in them such as "Working Out Playlist".
To rectify this, we attempted to set the INVocabulary for the playlist titles that a user has in the app, as suggested in this WWDC session: https://developer.apple.com/videos/play/wwdc2020/10060/
let vocabulary = INVocabulary.shared()
vocabulary.setVocabularyStrings(NSOrderedSet(array: [
"my favorites",
"recently added",
"working out playlist"
]), of: .mediaPlaylistTitle);
This seems to have no effect. We understand the note in https://developer.apple.com/documentation/sirikit/registering_custom_vocabulary_with_sirikit/ stating that "a few minutes" should be waited before testing custom vocabulary, but waiting upwards of 20 minutes and even restarting the device did not result in any of the custom vocabulary making a difference.
If these playlist names are set in AppIntentVocabulary.plist, "Recently Added" and "My Favorites" are able to be discovered as playlists, but the other failed test cases remain failing. The obvious shortcoming here is that these are not dynamic.
<key>ParameterVocabularies</key>
<array>
<dict>
<key>ParameterNames</key>
<array>
<string>INPlayMediaIntent.playlistTitle</string>
</array>
<key>ParameterVocabulary</key>
<array>
<dict>
<key>VocabularyItemIdentifier</key>
<string>working out playlist</string>
<key>VocabularyItemSynonyms</key>
<array>
<dict>
<key>VocabularyItemPhrase</key>
<string>working out playlist</string>
</dict>
</array>
</dict>
<dict>
<key>VocabularyItemIdentifier</key>
<string>recently added</string>
<key>VocabularyItemSynonyms</key>
<array>
<dict>
<key>VocabularyItemPhrase</key>
<string>recently added</string>
</dict>
</array>
</dict>
<dict>
<key>VocabularyItemIdentifier</key>
<string>my favorites</string>
<key>VocabularyItemSynonyms</key>
<array>
<dict>
<key>VocabularyItemPhrase</key>
<string>my favourites</string>
</dict>
<dict>
<key>VocabularyItemPhrase</key>
<string>my favorites</string>
</dict>
</array>
</dict>
</array>
</dict>
</array>
Given the above, our questions are as follows:
Is there documentation surrounding how Siri may pass along the mediaSearch in INPlayMediaIntent and how/why information may be left out?
Why does setting custom vocabulary with INVocabulary seem to have no effect, yet the same vocabulary in AppIntentVocabulary does have an effect?
Is the functionality we are experiencing to be expected, or should this be reported as a bug?
We've published the test app that we are using for debugging this functionality at this link: https://github.com/awojnowski/SiriTest
I'm not really sure if I'm using the right lingo here because there's so little documentation on this, so apologies in advance.
I have an app with a few custom intents that I'm attempting to transition to AppIntents. I have the newly transitioned intents showing up in the Shortcuts app as expected, however when I run them I get an immediate failure saying "The operation couldn't be completed" (see photo). Note that the "AppIntentsClient" class mentioned in the photo is the dependency I'm trying to import.
I've narrowed it down to the @Dependency that I'm using in my intent handler. At the top of the intent handler I have a line:
@Dependency
private var appIntentsClient: any AppIntentsClient // NOTE: AppIntentsClient is a protocol -- could that be the issue?
And if I comment out this line, the intent no longer throws that error.
I'm following the guidelines shown in sample apps by setting the dependency on my main app's startup in didFinishLaunchingWithOptions like so:
// gets called by the main app `didFinishLaunchingWithOptions`
func onDidFinishLaunching() {
let adapter = AppIntentsAdapter() //AppIntentsAdapter adheres to protocol AppIntentsClient
self.appIntentsAdapter = adapter
AppDependencyManager.shared.add(dependency: adapter)
MyAppShortcuts.updateAppShortcutParameters()
}
Unfortunately there is virtually no documentation around AppDependencyManager or AppDependencies in general. Both documentation pages have at most one line, but don't indicate why this would be failing for me. Is there any information out there on why these errors may be happening? I've also looked at the Console app to see if the OS logs anything, but nothing of value was found.
https://developer.apple.com/documentation/appintents/appdependencymanager
https://developer.apple.com/documentation/appintents/appdependency
I’ve set up a focus filter, but the perform() method in SetFocusFilterIntent isn't called when the focus mode is toggled on or off on my iPhone since I updated to iOS 18 beta (22A5326f).
I can reproduce the issue for my app, but focus filters are also broken for any third-party apps installed on my phone, so I guess it's not specific to how I've implemented my filter intent.
This used to work perfectly on iOS 17. I didn't change a single line of code, and it broke completely on the latest iOS 18 beta.
I've filed a bug report including a sysdiagnose (FB14715113).
To the developers out there, is this something you are also observing in your apps?
We have an app with carplay-messaging capability, and have successfully integrated our app in order to read out the list of unread messages.
However, if a single message arrives and our push notification appears, we are not able to have the Siri UI automatically read only that single message or announce it.
The 'list' UI appears (siri: "would you like to read your messages...") when tapping the notification, whereas we would like the 'item' UI to appear immediately with the "reply, repeat, don't reply" buttons.
Our intent handler service looks like this - basically the auto-generated one for a new Intent Handler Extension:
import Intents
// As an example, this class is set up to handle Message intents.
// You will want to replace this or add other intents as appropriate.
// The intents you wish to handle must be declared in the extension's Info.plist.
// You can test your example integration by saying things to Siri like:
// "Send a message using <myApp>"
// "<myApp> John saying hello"
// "Search for messages in <myApp>"
class IntentHandler: INExtension, INSendMessageIntentHandling, INSearchForMessagesIntentHandling, INSetMessageAttributeIntentHandling {
override func handler(for intent: INIntent) -> Any {
// This is the default implementation. If you want different objects to handle different intents,
// you can override this and return the handler you want for that particular intent.
return self
}
// MARK: - INSendMessageIntentHandling
// Implement resolution methods to provide additional information about your intent (optional).
func resolveRecipients(for intent: INSendMessageIntent, with completion: @escaping ([INSendMessageRecipientResolutionResult]) -> Void) {
if let recipients = intent.recipients {
// If no recipients were provided we'll need to prompt for a value.
if recipients.count == 0 {
completion([INSendMessageRecipientResolutionResult.needsValue()])
return
}
var resolutionResults = [INSendMessageRecipientResolutionResult]()
for recipient in recipients {
let matchingContacts = [recipient] // Implement your contact matching logic here to create an array of matching contacts
switch matchingContacts.count {
case 2 ... Int.max:
// We need Siri's help to ask user to pick one from the matches.
resolutionResults += [INSendMessageRecipientResolutionResult.disambiguation(with: matchingContacts)]
case 1:
// We have exactly one matching contact
resolutionResults += [INSendMessageRecipientResolutionResult.success(with: recipient)]
case 0:
// We have no contacts matching the description provided
resolutionResults += [INSendMessageRecipientResolutionResult.unsupported()]
default:
break
}
}
completion(resolutionResults)
} else {
completion([INSendMessageRecipientResolutionResult.needsValue()])
}
}
func resolveContent(for intent: INSendMessageIntent, with completion: @escaping (INStringResolutionResult) -> Void) {
if let text = intent.content, !text.isEmpty {
completion(INStringResolutionResult.success(with: text))
} else {
completion(INStringResolutionResult.needsValue())
}
}
// Once resolution is completed, perform validation on the intent and provide confirmation (optional).
func confirm(intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) {
// Verify user is authenticated and your app is ready to send a message.
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self))
let response = INSendMessageIntentResponse(code: .ready, userActivity: userActivity)
completion(response)
}
// Handle the completed intent (required).
func handle(intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) {
// Implement your application logic to send a message here.
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self))
let response = INSendMessageIntentResponse(code: .success, userActivity: userActivity)
completion(response)
}
// Implement handlers for each intent you wish to handle. As an example for messages, you may wish to also handle searchForMessages and setMessageAttributes.
// MARK: - INSearchForMessagesIntentHandling
func handle(intent: INSearchForMessagesIntent, completion: @escaping (INSearchForMessagesIntentResponse) -> Void) {
// Implement your application logic to find a message that matches the information in the intent.
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSearchForMessagesIntent.self))
let response = INSearchForMessagesIntentResponse(code: .success, userActivity: userActivity)
// Initialize with found message's attributes
response.messages = [INMessage(
identifier: "identifier",
conversationIdentifier: "convo1",
content: "I am so excited about SiriKit!",
dateSent: Date(),
sender: INPerson(personHandle: INPersonHandle(value: "sarah@example.com", type: .emailAddress), nameComponents: nil, displayName: "Sarah", image: nil, contactIdentifier: nil, customIdentifier: nil),
recipients: [INPerson(personHandle: INPersonHandle(value: "+1-415-555-5555", type: .phoneNumber), nameComponents: nil, displayName: "John", image: nil, contactIdentifier: nil, customIdentifier: nil)],
messageType: .text
)]
completion(response)
}
// MARK: - INSetMessageAttributeIntentHandling
func handle(intent: INSetMessageAttributeIntent, completion: @escaping (INSetMessageAttributeIntentResponse) -> Void) {
// Implement your application logic to set the message attribute here.
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSetMessageAttributeIntent.self))
let response = INSetMessageAttributeIntentResponse(code: .success, userActivity: userActivity)
completion(response)
}
}
Is there specific configuration required to allow display of a single message via tapping on the notification?
I am opening the Siri shortcut screen from the viewDidLoad method, as follows:
override func viewDidLoad() {
super.viewDidLoad()
// Present the Siri Shortcut screen to add Card Payment Intent
let viewController = INUIAddVoiceShortcutViewController(shortcut: INShortcut(intent: self.cardPaymentIntent)!)
viewController.modalPresentationStyle = .pageSheet
// Setting Delegate
viewController.delegate = self
self.present(viewController, animated: true, completion: nil)
}
// Delegate Method Conformance :: INUIAddVoiceShortcutViewControllerDelegate
@available(iOS 12.0, *)
func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController, didFinishWith voiceShortcut: INVoiceShortcut?, error: Error?) {
controller.dismiss(animated: true, completion: nil)
// The issue is here. Whether we add the or Dismiss the Siri shortcut screen without adding it, this delegate gets called.
}
@available(iOS 12.0, *)
func addVoiceShortcutViewControllerDidCancel(_ controller: INUIAddVoiceShortcutViewController) {
controller.dismiss(animated: true, completion: nil)
}
// Card Payment Intent
public var cardPaymentIntent: CardPaymentIntent {
let intent = CardPaymentIntent()
intent.suggestedInvocationPhrase = NSLocalizedString("Pay my credit card", comment: "")
return intent
}
Whenever I present the siri shortcut screen, either I add the shortcut or dismiss the screen without adding. In both cases , the shortcut is added. And this method is called every time
func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController, didFinishWith voiceShortcut: INVoiceShortcut?, error: Error?)
Any solution ? while I dismiss the screen, i want it not to be added into the shortcut
I am writing a communication app that relies on the INShareFocusStatusIntentHandling protocol. However, it appears this API is not functional, even with the proper permissions and entitlements.
Given the example code here, I am unable to trigger the logs in the INShareFocusStatusIntentHandling extension.
In this code, when enabling or disabling focus, line 33 of IntentHandler.swift never gets logged, even though FocusStatusCenter is authorized for parent app, UserNotifications authorized for parent app (target), and Communication Notifications entitlement has been added to the parent app. I am also unable to hit any breakpoints in the extension. It seems as if the extension is simply never triggered -- maybe even broken at the OS-level.
I have tried both iOS 17 and the latest 18 beta. Other users have reported similar difficulties in these forums.
To replicate, Install the example app. Give the app UserNotifications and FocusStatus permissions. Background the app. Change focus status. Check console. Notice that the extension handler is never triggered/logged.
1
I have just added a share extension with an audio predicate, but in the "Files" app, my app doesn’t appear in the "Share" menu for audio files. The Share Activity View Controller does not show my app. There seems to be no way to make it work. I have already spent 2 days googling this and searching forums. Some users say this is an iOS bug, while others suggest restarting the device. Nothing helps.
Just build and run the ShareExtension using the Files app. Try sharing any file and note that my app does not appear in the share list options. I am using the latest iOS 17.5 release version.
2
After starting to implement the sharing feature in my app Anywhere Offline Music Player, I noticed that my phone/iPad freezes when any share dialog from any place in the system is being shown. Additionally, all other apps are missing from the share list. When I try to share a file from any app, the share dialog first appears as a shadow, then glitches, and finally shows up, but the Files app option is missing, so I can't save the shared file. This issue persists even after removing my app, and only a reboot helps. Other users report this happening regardless of whether my app is installed or not.
Sometimes it works without any lags, but mostly it does not. I have no idea what this depends on. The same issue occurs on iPads using the latest beta versions. Removing my app and rebooting the device temporarily "fixes" this.
I create a toggle component based on Toggle
public struct Checkbox: View {
...
public init(...) {
...
}
public var body: some View {
return HStack(spacing: 8) {
ZStack {
Toggle("", isOn: $isPrivateOn)
...
}
...
}
}
}
how can I create a init method to support init with AppIntent like:
// Available when SwiftUI is imported with AppIntents
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension Toggle {
/// Creates a toggle performing an `AppIntent`.
///
/// - Parameters:
/// - isOn: Whether the toggle is on or off.
/// - intent: The `AppIntent` to be performed.
/// - label: A view that describes the purpose of the toggle.
public init<I>(isOn: Bool, intent: I, @ViewBuilder label: () -> Label) where I : AppIntent
}
I'm encountering a crash in my SwiftUI app when it is opened via an AppIntent. The app runs perfectly when launched by tapping the app icon, but it crashes when opened from an intent.
Here is a simplified version of my code:
import AppIntents
import SwiftData
import SwiftUI
@main
struct GOGODemoApp: App {
@State
private var state: MyController = MyController()
var body: some Scene {
WindowGroup {
MyView()
//.environment(state) // ok
}
.environment(state) // failed to start app, crash with 'Dispatch queue: com.apple.main-thread'
}
}
struct MyView: View {
@Environment(MyController.self) var stateController
var body: some View {
Text("Hello")
}
}
@Observable
public class MyController {
}
struct OpenIntents: AppIntent {
static var title: LocalizedStringResource = "OpenIntents"
static var description = IntentDescription("Open App from intents.")
static var openAppWhenRun: Bool = true
@MainActor
func perform() async throws -> some IntentResult {
return .result()
}
}
Observations:
The app works fine when launched by tapping the app icon.
The app crashes when opened via an AppIntent.
The app works if I inject the environment in MyView instead of in WindowGroup.
Question:
Why does injecting the environment in WindowGroup cause the app to crash when opened from an intent, but works fine otherwise? What is the difference when injecting the environment directly in MyView?
I would like to split up my intents into smaller intents with more atomic pieces of functionality that I can then call one intent from another. For example:
struct SumValuesIntent: AppIntent {
static var title: LocalizedStringResource { "Sum Values" }
let a: Int
let b: Int
init(a: Int, b: Int) {
self.a = a
self.b = b
}
init() {
self.init(a: 0, b: 0)
}
func perform() async throws -> some IntentResult {
let sum = a + b
print("SumValuesIntent:", sum)
return .result(value: sum)
}
}
struct PrintValueIntent: AppIntent {
static var title: LocalizedStringResource { "Print Value" }
let string: String
init(string: String) {
self.string = string
}
init() {
self.init(string: "")
}
func perform() async throws -> some IntentResult {
print("PrintValueIntent:", string)
return .result()
}
}
What is the best way to chain intents like these? I tried
.result(opensIntent: PrintValueIntent(string: String(describing: sum)))
as the return type of SumValuesIntent.perform but that doesn't seem to work. Then I tried
try await PrintValueIntent(string: String(describing: sum)).perform()
as the return type and that works but I'm not sure that's the correct way to do it.