As described on
http://www.openradar.me/45024092
I am facing the same scenario as described on the comment below:
As per API the result of the call to https://developer.apple.com/documentation/sirikit/intent_handling_infrastructure/requesting_authorization_to_use_siri
INPreferences.requestSiriAuthorization({status in
resolve(status.rawValue)
})
should be recalled and block execution when it's "denied" but it seems to be ignored. and the feature can be accessed (shortcuts being created etc)
Cautious developers would check for the value of the INSiriAuthorizationStatus and block feature access based on the result but that would instead lead to a deadlock as no toggles on Settings-> App -> Siri would trigger a new user prompt for authorisation (as suggested by docs).
As per attached screenshot all toggles are enabled besides the user denied the Siri permission request.
No documented changes on API I could find on the iOS releases notes > 11.0
Is there a gap on the documentation or is it 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
184 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I am developing a shortcut for an application that is currently in production. The shortcut essentially involves opening the application and launching a notification so that the AppDelegate initiates a process to scan NFC tags.
To achieve this, I have an AppIntent that overrides the variable openAppWhenRun = true and an AppShortcutsProvider to implement this intent.
The problem arises when a user updates to the latest version of the application and tries to implement this shortcut through an automation. The following error appears: "When 'Reader' is detected" encountered an error: The action 'Scan DMA tags' could not run because an internal error occurred.
This does not always happen, only on some devices. However, if we uninstall and reinstall the application, it works perfectly. But this is not a viable solution since the application uses a database and data loss from frequent uninstallations is not acceptable.
Any solution?
I have tried to replicate the error but have been unable to do so. This issue has occurred on both iOS 16 and iOS 17.
Two structs from the AppIntents framework should be made Sendable: DisplayRepresentation and IntentDescription.
I have a basic Widget with a button to toggle the home lights, the buttons triggers the following AppIntention:
import WidgetKit
import AppIntents
struct ConfigurationAppIntent: WidgetConfigurationIntent {
static var title: LocalizedStringResource = "Bulb state"
static var description = IntentDescription("This is an example widget.")
}
struct ToggleStateIntent: AppIntent {
static var title: LocalizedStringResource = "Toggle light state"
init(){
}
func perform() async throws -> some IntentResult {
await WizClient.shared.toggleState()
return .result()
}
}
The problem is that I must be running the app with xcode (in my phone, not simulator) to work fine, when I stop xcode the button must be pressed two times to trigger the AppIntention.
The toggle function works well on the app with a toggle component.
Here is the widget:
import WidgetKit
import SwiftUI
struct Provider: AppIntentTimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
SimpleEntry(date: Date(), configuration: ConfigurationAppIntent())
}
func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry {
SimpleEntry(date: Date(), configuration: configuration)
}
func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline<SimpleEntry> {
let timeline = Timeline(entries: [SimpleEntry(date: Date(), configuration: configuration)], policy: .atEnd)
return timeline
}
}
struct SimpleEntry: TimelineEntry {
let date: Date
let configuration: ConfigurationAppIntent
}
struct BulbActionsEntryView : View {
var entry: Provider.Entry
var body: some View {
HStack {
Button(intent: ToggleStateIntent()){
Text("Toggle")
}
}
.padding(.vertical)
}
}
struct BulbActions: Widget {
let kind: String = "BulbActions"
var body: some WidgetConfiguration {
AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in
BulbActionsEntryView(entry: entry)
.containerBackground(.fill.tertiary, for: .widget)
}
}
}
extension ConfigurationAppIntent {
fileprivate static var test: ConfigurationAppIntent {
let intent = ConfigurationAppIntent()
print("Intent -> \(intent)")
return intent
}
}
#Preview(as: .systemSmall) {
BulbActions()
} timeline: {
SimpleEntry(date: .now, configuration: .test)
}
I have added an "App Intents Extension" target to my main application in macOS. This generated the below two files:
TWAppIntent.swift
import AppIntents
struct TWAppIntent: AppIntent {
static var title: LocalizedStringResource = "TWAppIntentExtension"
static var parameterSummary: some ParameterSummary {
Summary("Get information on \(\.$TWType)")
}
//launch app on running action
static var openAppWhenRun: Bool = true
// we can have multiple parameter of diff types
@Parameter(title: "TWType")
var TWType: String
func perform() async throws -> some IntentResult & ReturnsValue<String> & ProvidesDialog {
return .result(value: TWType, dialog: "Logged break.")
}
}
TWAppIntentExtension.swift
import AppIntents
@main
struct TWAppIntentExtension: AppIntentsExtension {
}
I m able to build the extension target and I my intent action is available in the shortcuts app. However, on launching a shortcut with the above created intent action. I m getting the below popups:
I have identified what is causing this error. Setting the openAppWhenRun to true is causing this error. I don't get this when it is set to false. This property is supposed to launch the application, but can someone help me understand why is it happening? This is only causing the error when using this property for AppIntent Extension and not for In app handling for the AppIntent.
Can we not launch our application from AppIntent extension?
Hello,
I have an app with two AppIntents. I invoke first AppIntent with my voice command, then I would like invoke the second AppIntent after the first one. I have implemented the necessary return type for the first AppIntent. My first AppIntent is invoked and executes successfully, however when it calls the second AppIntent, everything inside perform() method in the second AppIntent works but Siri dialog. Siri doesn't say the dialog in the second AppIntent.
Below implementation details for my two AppIntents together with AppShortcutsProvider. I appreciate any help.
struct MyFirstAppIntent : AppIntent {
static let title: LocalizedStringResource = "Show My Usages"
func perform() async throws -> some ProvidesDialog & OpensIntent {
let dialogStr = IntentDialog(stringLiteral: "You have a package")
print("I'm in first AppIntent")
return .result(opensIntent: MySecondAppIntent(), dialog: dialogStr)
}
struct MySecondAppIntent: AppIntent {
static let title: LocalizedStringResource = "Show My Usages"
func perform() async throws -> some IntentResult & ReturnsValue<String> & ProvidesDialog {
print("I'm in second AppIntent")
return .result(value: "Listing Packages",
dialog: "You have activated Default")
}
struct MyVoiceShortcutProvider : AppShortcutsProvider {
@AppShortcutsBuilder
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: MyFirstAppIntent(),
phrases: ["Call my first intent \(.applicationName)"]
);
AppShortcut(
intent: MySecondAppIntent(),
phrases: ["Call my second intent \(.applicationName)"]
);
}
}
Hi,
After upgrading to Xcode 15.3 (15E204a) AppIntents unexpectedly stopped working on iOS 16.
System error occurs when you try to run AppIntent on device with iOS 16, Shortcuts app just shows error alert.
There are errors in device's logs:
error Could not find an intent with identifier , mangledTypeName: Optional("")
It seems to be an issue with extract.actionsdata file, generated by appintentsmetadataprocessor. "mangledTypeName" parameter is empty for action descriptors, though it was fulfilled when building with Xcode 14.2 and different version of generator.
If I manually set this property in xcarchive and sign it everything works fine.
The issue is reproducible with Xcode 15.4 which is currently in beta.
Have anyone experienced this or have any solution more solid than editing metadata files after build?
I have created an intent using AppIntent and this intent(TWIntent in the code below) can be seen in the shortcuts app as an action to create the shortcut.
I am using AppShortcutProvider to create the shortcut so that user can directly make use of it. However, my shortcut does not appear in the shortcut app. The phrases used also do not launch the intent in the spotlight search. Below is my AppShortcutProvider file:
@available(macOS 13.0, *)
struct TWShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: TWIntent(),
phrases: [
"Open Intent in \(.applicationName)",
"Open \(.applicationName) Intent",
"Open my Intent in \(.applicationName)",
"Open my \(.applicationName) Intent",
"Open TWIntent"
],
shortTitle: "Open TWIntent",
systemImageName: "rectangle.stack.fill"
)
}
static var shortcutTileColor: ShortcutTileColor = .lightBlue
}
Is there something I m missing? Also can these phrases be used for siri launch in macOS because the documentation mentions that macOS does not have siri capability?
Below is my AppIntent file:
import SwiftUI
@available(macOS 13, *)
struct TWIntent: AppIntent {
static let title: LocalizedStringResource = "TWIntent"
static var description = IntentDescription("try adding this sample action as your TW shortcut")
//launch app on running action
static var openAppWhenRun: Bool = false
static var parameterSummary: some ParameterSummary {
Summary("Get information on \(\.$TWType)")
}
@Parameter(title: "TWType", description: "The type to get information on.")
var TWType: String
func perform() async throws -> some IntentResult & ReturnsValue<String> & ProvidesDialog {
//perform essential task here to update the application content
return .result(value: TWType, dialog: "Logged a 15 minute break.\(TWType)")
}
}
I've created widget that opens app on specific view: .widgetUrl(URL(string: "myapp://Dashboard/SpecialView"))
It works alright so i know deep links are working. So after that i created Shortcuts.swift file in my main app and added this:
import AppIntents
import UIKit
@available(iOS 16, *)
struct StartRecordingIntent : AppIntent {
static var title: LocalizedStringResource = "Special"
func perform() async throws -> some IntentResult {
let url = URL(string: "myapp://Dashboard/SpecialView")
DispatchQueue.main.async {
UIApplication.shared.open(url!, options: [:], completionHandler: nil)
}
return .result()
}
}
This intent created shortcut "Special" in shortcut list, and when run, should open exactly the same view as the widget. But all im getting is error:
Failed to open URL myapp://Dashboard/SpecialView: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1
"The request to open "com.myapp" failed."
UserInfo={BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000dd7960
{Error Domain=FBSOpenApplicationErrorDomain Code=3
"Application com.myapp is neither visible nor entitled, so may not perform un-trusted user actions."
I don't understand what i'm doing wrong and why can't i open app from shortcut exactly like widget does
I'm using the TrailsSampleApp (in the AppIntentsSampleApp project which is provided by Apple. According to the code, if you use the "Get conditions with TrailsSampleApp" and provide a trail that is NOT in the suggested entities, it should pass control to the following TrailEntityQuery extension.
/// An EntityStringQuery extends the capability of an EntityQuery by allowing people to search for an entity with a string.
extension TrailEntityQuery: EntityStringQuery {
/**
To see this method, configure the Get Trail Info intent in the Shortcuts app. A list displays the suggested entities.
If you search for an entity not in the suggested entities list, the system passes the search string to this method.
- Tag: string_query
*/
func entities(matching string: String) async throws -> [TrailEntity] {
Logger.entityQueryLogging.debug("[TrailEntityQuery] String query for term \(string)")
return trailManager.trails { trail in
trail.name.localizedCaseInsensitiveContains(string)
}.map { TrailEntity(trail: $0) }
}
}
It says if you configure the Get Trail Info section in the Shortcuts App, control will be passed to this entities() function. However, it doesn't say how to configure it.
Any suggestions or help?
I'm adding AppIntents to my existing "ShopList" app and I'm having two problems that I think are related.
I can't get shortcuts (or Siri) to work when I pass a parameter to an intent. It works if I don't pass a parameter though.
My StoreEntityQuery.suggestedEntities function is not being called during initialization.
I have an AppIntentsShortcutProvider defined as follows.
class ShopListShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(intent: FindStore(), phrases: [
"Find \(\.$store) store in \(.applicationName)"
],
shortTitle: "Find Store",
systemImageName: "cart")
}
}
Details below. I would appreciate any suggestions on what I'm missing or doing wrong.
In my AppDelegate "didFinishLaunchingWithOptions" function, I call ShopListShortcuts.updateShortcutParameters.
The FindStore struct is defined as follows.
struct FindStore: AppIntent {
static var title: LocalizedStringResource = "Find Store"
static var description = IntentDescription("Finds a store.")
static var openAppWhenRun: Bool = false
@Parameter(title: "Store", description: "The store.")
var store: StoreEntity
@MainActor
func perform() async throws -> some IntentResult {
print("performing intent with \(store.id) and \(store.name)")
return .result()
}
}
The StoreEntity is defined as follows.
struct StoreEntity: AppEntity {
...
static var defaultQuery = StoreEntityQuery()
var id: Store.ID
@Property(title: "Store Name")
var name: String
...
}
And finally the StoreEntityQuery is defined as follows.
struct StoreEntityQuery: EntityQuery {
func entities(for identifiers: [StoreEntity.ID]) async throws -> [StoreEntity] {
print("entities call")
return ...
}
func suggestedEntities(for identifiers: [StoreEntity.ID]) async throws -> [StoreEntity] {
print("suggested entities call")
return ...
}
}
according to:
https://developer.apple.com/documentation/appintents/appintent
one should be able to create an optional parameter to a shortcut with "@OptionalParameter". But it seems that macro doesn't exist anywhere outside of that 1 web page.
Is it not implemented?
Hi,
I'm new to Swift development and encountering an issue that I believe may be due to an error on my part.
I have two questions regarding the following code:
import AppIntents
import SwiftUI
import SwiftData
@available(iOS 17.0, *)
struct CopiarEventoIntent: AppIntent {
@Environment(\.modelContext) private var context
@Parameter(title: "Nome do Evento")
var name: String
@Parameter(title: "Data Inicial")
var datai: Date
@Parameter(title: "Data Final")
var dataf: Date
@Parameter(title: "Tipo de Evento")
var tipo: String
@Parameter(title: "Endereço")
var endereco: String
@Parameter(title: "Lembrete")
var reminder: Bool
static var title: LocalizedStringResource = "Adicionar Eventos"
static var description = IntentDescription("Copiar Eventos e alterar datas", resultValueName: "Resultado")
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog {
let calData = CalData(title: name, datei: datai, datef: dataf, tipo: tipo, endereco: endereco,reminder: reminder)
context.insert(calData)
return .result(dialog: "Evento copiado com sucesso!")
}
}
@available(iOS 15.0, *)
struct AppShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: CopiarEventoIntent(),
phrases: [
"Copiar Evento"
],
shortTitle: "Copiar Evento",
systemImageName: "square.and.arrow.down"
)
}
}
@available(iOS 15.0, *)
struct ShortcutSelectionView: View {
@Environment(\.modelContext) private var context
@Query(sort: \CalData.title) private var caldatas: [CalData]
@State private var selectedEvent: CalData?
var body: some View {
List(caldatas, id: \.self) { eventData in
Button(action: {
selectedEvent = eventData
handleEventSelection()
}) {
Text(eventData.title)
}
}
}
private func handleEventSelection() {
guard selectedEvent != nil else { return }
}
}
When I run the shortcut, gives me the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot insert 'CalData' in this managed object context because it is not found in the associated managed object model.
I attempted to save this using SwiftData with the following model:
import SwiftData
@Model
class CalData {
var title : String
var datei : Date
var datef : Date
var tipo : String
var endereco : String
@Relationship(deleteRule: .cascade) var caldataval = [CalDataVal]()
var reminder: Bool = false
init(title:String, datei:Date, datef:Date, tipo:String, endereco:String, reminder:Bool){
self.title = title
self.datei = datei
self.datef = datef
self.tipo = tipo
self.endereco = endereco
self.reminder = reminder
}
}
As for the second question, how can I add a parameter that can have multiple values to save them to EventDataVal, resembling a one-to-many relationship:
import SwiftData
@Model
class CalDataVal {
var name : String
var value : Double
init(name:String, value:Double){
self.name = name
self.value = value
}
}
Thanks in advanced
I am exploring Appi-Intent and Appshortcut. We can create an action shortcut by using the following code.
struct WatchListShortcut: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: WatchListAppIntent(),
phrases: [
"Tell \(.applicationName) to open first item in watch list",
],
shortTitle: "WatchList item",
systemImageName: "systemimage"
)
}
}
What I want to show an entity shortcut like shown in the below screenshot.
linkText
I am not sure how to create the shortcut like Assigned one in the above screen.
Currently I am trying to create some shortcuts for my iOS 17 app. The AppIntent looks like this:
class PostClass{
public init() {
let url = URL(string: "http://myurl")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
struct Message: Encodable {
let device_type: String
}
let message = Message(
device_type: "device"
)
let data = try! JSONEncoder().encode(message)
request.httpBody = data
request.setValue(
"application/json",
forHTTPHeaderField: "Content-Type"
)
self.request = request
}
}
var activateDevice = PostClass()
@available(iOS 17, *)
struct ActivateIntent: AppIntent {
static let title: LocalizedStringResource = "Activate"
func perform() async throws -> some IntentResult {
let task = URLSession.shared.dataTask(with: activateDevice.request) { data, response, error in
let statusCode = (response as! HTTPURLResponse).statusCode
if statusCode == 200 {
print("SUCCESS")
} else {
print("FAILURE")
}
}
task.resume()
return .result()
}
}
Unfortunately, the shortcut throws an error after every second execution. I looked into the ips-file and saw the following traceback:
Thread 2 Crashed:
0 Runner 0x1028ddd30 closure #1 in ActivateIntent.perform() + 388
1 CFNetwork 0x1a6f39248 0x1a6f2a000 + 62024
2 CFNetwork 0x1a6f57210 0x1a6f2a000 + 184848
3 libdispatch.dylib 0x1adced13c _dispatch_call_block_and_release + 32
4 libdispatch.dylib 0x1adceedd4 _dispatch_client_callout + 20
5 libdispatch.dylib 0x1adcf6400 _dispatch_lane_serial_drain + 748
6 libdispatch.dylib 0x1adcf6f64 _dispatch_lane_invoke + 432
7 libdispatch.dylib 0x1add01cb4 _dispatch_root_queue_drain_deferred_wlh + 288
8 libdispatch.dylib 0x1add01528 _dispatch_workloop_worker_thread + 404
9 libsystem_pthread.dylib 0x201dd4f20 _pthread_wqthread + 288
10 libsystem_pthread.dylib 0x201dd4fc0 start_wqthread + 8
Is there any way to locate the error with these information? Has it something to do with the fact that my code is not thread-safe? Or is there any internal bug?
Grateful for any help, thanks in advance!
Description:
Problem Statement:
State the problem clearly: The Siri Intent for the "Next","Previous","Repeat" command is not working as expected within the Speech Framework.
Steps to Reproduce:
Provide a detailed description of the steps to reproduce the issue. For example:
Open the Speech Framework application.
Tap on the Siri button to activate voice input.
Say "Next" to trigger the intended action.
Observe that the action is not executed correctly.
IN Our Demo App:
Steps of my demo application as below:
Open SIRI
Speak: Check
In Response: Open dialog as below:
What user wants?
One 2) Next 3) Yes 4) Goodbye
Speak: Next
In Response: SIRI repeat same dialog (Step: 2)
3) Speak: Yes, or One or Goodbye
In Response: SIRI goes to next dialog.
Expected Behavior:
Should be get "Next" Value in siri kit intent or app intent.
Actual Behavior:
But it give previous user input key word give in siri kit intent and recuresively repeat dialog in app intent.
Device versions and Region and Language:
Device model: IPhone 11 and OS version: 17.4.1
Region: Us and Language: English(US)
Impact:
User Cant use Iterative dialog in one context.
Additional:
How Different command work on app intent and siri kit intent on diffrent diffrent device. you can follow No vise in order.
|| No || Diffrent Device test on Diffrent sinario || SiriKit intent || app Intent ||
| 1 | ISG iPhone 11 - Next | Not | Not |
| 2 | ISG iPhone 11 - Yes | Not | Yes (But Using Enum) |
| 3 | ISG iPhone 11 - GoodBye | Not | Yes (But Using Enum) |
| 4 | ISG iPhone 11 - One | Yes | Yes |
| 5 | iPad - Next | Not | Not |
| 6 | iPad - One | Yes | Yes |
| 7 | iPad - GoodBye | Not | Yes |
| 8 | iPad - Yes | Not | Yes |
| 9 | Simulator - iPhone 15 - Next, Yes, One, GoodBye | Yes | Yes |
Please help me in it...
I'm currently exploring how to implement the AppIntent parameter with a list of apps similar to what's shown in the screenshots provided below:
I'm particularly interested in how the searchable list of apps is implemented. My current approach involves creating an enum for the apps, but it lacks searchability and requires manual addition of each app.
Does anyone have an idea on how this functionality might be implemented? It appears that the searchable list might be a native Apple view, but I haven't been able to find any documentation or resources on it. Any insights or pointers would be greatly appreciated!
Creating AppEntity objects for use as AppIntents to do filtering no longer works in iOS 17.4. If you have a prior shortcut setup that does that, then it will work. It seems some apps still work, but mostly i see the app shortcut action no longer has the Filtering options.
Hello, I am developing a Chat application, and I was able to successfully implement INSendMessageIntent to be able to have suggestions in Share Extensions with some of my contacts.
I've noticed that after a day or two, avatars are lost, and 2 tested devices are displaying empty background.
When I use my app to send a message, this new chat appears with avatar properly, but just after some time it goes away.
I am using:
let avatarImage = INImage(url: avatarUrl)
intent.setImage(avatarImage, forParameterNamed: \.speakableGroupName)
where avatarUrl can be a file created in NSTemporaryDirectory or just a file in my shared AppGroup directory.
As you can see, Telegram suggestions work fine, suggestions from my app works well as well when I donate the intent, but after some time avatars just goes away
Does apple perform some avatar caching, so when I donate the intent avatars are stored for Share sheet somewhere? Or they always use my local url and I need to make sure it's not deleted?
Hello,
We're interested in using the PTT Framework with our PTT capable hardware, as the framework has intended. The problem is activating Siri with any of our specified Intent's doesn't work when the phone is locked.
The iPhone always says "You'll have to unlock your iPhone first".
Reading up on the problem, it seems pretty common in the fact that Apple doesn't allow Siri Intents to be executed while the phone is locked.
It's a sensible precaution by default, but there are countless threads of real use cases that users want to use Siri without unlocking (with PTT, or well, without).
There appears to be no options for PTT to enable this, any flags on the Siri Intent to allow benign App actions or queries, user UI configuration through Settings -> Siri & Search to manually allow it even when the phone is locked. Neither are there any entitlements (that I'm aware of) that would allow trivial and non-secure Siri App Intents.
The only advice we have for our users (and albeit against the intention of the limitation in the first place) is to: Disable Auto Lock, Disable Face ID and to Disable Passcode.
It is in fact 2024, and users do expect a better experience than this with Siri, or am I missing something?