Share intents from within an app to drive system intelligence and show the app's actions in the Shortcuts app.

Posts under Intents tag

54 Posts
Sort by:
Post not yet marked as solved
0 Replies
82 Views
when i was develop ShareExtension, and I donate a intent to share suggestion, and it appeared on my share sheet, but I launched the ShareExtension by clicked icon in suggestion list. and i executed the following code in my project, i got nil of intent. and extensionContext is not nil. '''self.extensionContext.intent''' I would greatly appreciate some insight of what could be possible going wrong here. Thanks in advance!
Posted
by GuidoPu.
Last updated
.
Post marked as solved
1 Replies
134 Views
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!
Posted Last updated
.
Post not yet marked as solved
2 Replies
284 Views
Hi! I have an AppShortcutsProvider that has been marked @available(iOS 17.0, *), because all Intents used within it are only available in iOS 17. So the static var appShortcuts should only be accessible in iOS 17, obviously. Now this code has been released and works fine for iOS 17 users. But I just noticed that around 150 iOS 16 users have crashed in the static var appShortcuts, or more specifically, the defaultQuery of one of the Intents. This should not be possible, as neither the AppShortcutsProvider, nor the Intent is exposed to iOS 16, they are marked as @available(iOS 17.0, *). Any idea why this could happen? Here is the crash log: Crashed: com.apple.root.user-initiated-qos.cooperative 0 libswiftCore.dylib 0x3e178c swift::ResolveAsSymbolicReference::operator()(swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*) 1 libswiftCore.dylib 0x40bec4 swift::Demangle::__runtime::Demangler::demangleSymbolicReference(unsigned char) 2 libswiftCore.dylib 0x408254 swift::Demangle::__runtime::Demangler::demangleType(__swift::__runtime::llvm::StringRef, std::__1::function<swift::Demangle::__runtime::Node* (swift::Demangle::__runtime::SymbolicReferenceKind, swift::Demangle::__runtime::Directness, int, void const*)>) 3 libswiftCore.dylib 0x3e9680 swift_getTypeByMangledNameImpl(swift::MetadataRequest, __swift::__runtime::llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) 4 libswiftCore.dylib 0x3e4d9c swift_getTypeByMangledName 5 libswiftCore.dylib 0x3e50ac swift_getTypeByMangledNameInContext 6 MyApp 0x3f6b8c __swift_instantiateConcreteTypeFromMangledName (<compiler-generated>) 7 MyApp 0x640e3c one-time initialization function for defaultQuery + 146 (IntentAction.swift:146) 8 libdispatch.dylib 0x3eac _dispatch_client_callout 9 libdispatch.dylib 0x56ec _dispatch_once_callout 10 MyApp 0x64109c protocol witness for static AppEntity.defaultQuery.getter in conformance IntentAction + 124 (IntentAction.swift:124) 11 AppIntents 0x15c760 _swift_stdlib_malloc_size 12 AppIntents 0x19dfd4 __swift_destroy_boxed_opaque_existential_1Tm 13 MyApp 0x52dadc specialized ActionIntent.init(action:) + 41 (ActionIntent.swift:41) 14 MyApp 0x52df80 specialized static MyShortcuts.appShortcuts.getter + 17 (MyShortcuts.swift:17)
Posted Last updated
.
Post not yet marked as solved
0 Replies
148 Views
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?
Posted Last updated
.
Post not yet marked as solved
0 Replies
240 Views
So I'm working on a logging app that uses Siri to log diaper changes for babies. There are 3 types of diaper changes, wet, dirty, both. I created a enum for these values in the intent definition file and made it configurable and resolvable. in the resolve function, I added this line of code public func resolveDiaperType(for intent: DiaperIntentIntent, with completion: @escaping (DiaperTypeResolutionResult) -> Void) { let needsValue = intent.diaperType == .unknown if needsValue { completion(.needsValue()) } else { completion(.success(with: intent.diaperType)) } } But as soon as .needsValue() is called, the UI will ask user to select one value, and then crash the app. I tried removing a lot of different params and code blocks, needsValue is the only thing that's crashing for me. If I make the default diaperType parameter as .dirty instead of .unknown, it works. Basically it won't let me work with an empty enum parameter. I get the SIGABRT error and the app crashes. I have like 4 intents. 3 of them uses enums. All 3 crash on the enum input UI. all 3 work correctly when the enum is given a value instead of .unknown. The problem is, I NEED to ask user the type. If I give it a default value and resolve it with .needsValue(), it still crashes. I cannot ask the user for a value. I haver made siri intents with enums input before. And those intents STILL WORK. They were just made for older Xcode versions Is this an Xcode bug? Testing on iOS 17.2 simulator Xcode 15.2
Posted Last updated
.
Post not yet marked as solved
0 Replies
227 Views
My app has an AppIntent that returns a collection of AppEntity items. Using a shortcut with the repeat with each action to loop the entities, it prompts me multiple times to allow to share the entities (I select "Always Allow" on the first one, but it keeps asking over and over). All the prompts after the first one, shows an incorrect note saying something like: "Previously this shortcut was allowed to share 1 item with …" the count of items shared is always wrong, for example, if I initially selected "Always Allow" for 10 entities on the first prompt, the second says previously 1 item, the third prompt actually has the count right, saying 10 items, and then a fourth prompt (seems to be the last one) says something like 40 items Some more facts: This issue does not happen for example when I fetch entities from a system based intent, like get calendar events. It correctly only prompt for my permission once My app is already on the app store
Posted Last updated
.
Post not yet marked as solved
1 Replies
224 Views
guard let fileURL = intent.attachments?.first?.audioMessageFile?.fileURL else { print("Couldn't get fileNameWithExtension from intent.attachments?.first?.audioMessageFile?.fileURL?.lastPathComponent") return failureResponse } defer { fileURL.stopAccessingSecurityScopedResource() } let fileURLAccess = fileURL.startAccessingSecurityScopedResource() print("FileURL: \(fileURLAccess)") let tempDirectory = FileManager.default.temporaryDirectory let tempFileURL = tempDirectory.appendingPathComponent(UUID().uuidString + "_" + fileURL.lastPathComponent) do { // Check if the file exists at the provided URL guard FileManager.default.fileExists(atPath: fileURL.path) else { print("Audio file does not exist at \(fileURL)") return failureResponse } fileURL.stopAccessingSecurityScopedResource() // Check if the temporary file already exists and remove it if necessary if FileManager.default.fileExists(atPath: tempFileURL.path) { try FileManager.default.removeItem(at: tempFileURL) print("Removed existing temporary file at \(tempFileURL)") } // Copy the audio file to the temporary directory try FileManager.default.copyItem(at: fileURL, to: tempFileURL) print("Successfully copied audio file from \(fileURL) to \(tempFileURL)") // Update your response based on the successful upload // ... } catch { // Handle any errors that occur during file operations print("Error handling audio file: \(error.localizedDescription)") return failureResponse } guard let audioData = try? Data(contentsOf: tempFileURL), !audioData.isEmpty else { print("Couldn't get audioData from intent.attachments?.first?.audioMessageFile?.data") return failureResponse } Error: FileURL: false Audio file does not exist at file:///var/mobile/tmp/SiriMessages/BD57CB69-1E75-4429-8991-095CB90959A9.caf is something I'm missing?
Posted Last updated
.
Post not yet marked as solved
0 Replies
242 Views
AppIntens can be used as actions when working with Shortcut Automation. iOS offers a bunch of different triggers to start an automation, such as "Time of Day", "Email", "Transaction", etc. Depending on the trigger one can then pass different "Shortcut input" values as parameters to the App Intent. While in many cases the expected type is quite obvious, this is not always the case. An Email type input for example offers Subject, Sender, Recipients, Attachments, Content, Name. Subject will be most likely a String. But is Sender also a String or maybe an IntentPerson? Is Recipients a String (e.g. comma separated) or a collection? Is Attachments a [String], [URL] or [IntentFile]? How to I find out of which types these inputs have? Is there a better way than guessing and trial and error? The documentation provides very little information about supported types in general and I could find nothing about the types used by different triggers. Additionally each "Shortcut input" offers it self as parameter. So the Email type input does not only offer Subject, Sender, etc. as input parameters but also Email. What parameter type does an intent need no accept in order to receive on Email object? Thank you very much for your help.
Posted
by Agenor.
Last updated
.
Post not yet marked as solved
0 Replies
201 Views
Hello guys Im searching a way to create, or to use an existent shortcut to limit timetables for certain applications. My goal is not to limit the daily maximum time for using an application. An example: my Iphone would not permit me to use tiktok from 6.00 AM to 8.00 AM Thank you in advance
Posted
by gallo00.
Last updated
.
Post not yet marked as solved
0 Replies
256 Views
I am unable to attach the Intents extension. it is showing 'waiting for attach' for a prolonged period.
Posted
by Theju.
Last updated
.
Post not yet marked as solved
0 Replies
272 Views
I wanna add an intents app extension on iOS 15, I'm following the link https://toolboxpro.app/blog/adding-shortcuts-to-an-app-1. It works fine when running the extension target on device, but here comes the error "Could not run Make Uppercase,There was a problem with the app" when I running the main target. There is no exception or breakpoint in Xcode so I don't know what's the problem. Any help will be appreciate, thanks.
Posted
by WWWang.
Last updated
.
Post marked as solved
2 Replies
877 Views
According to the WWDC19 video (Introducing Parameters for Shortcuts), the parameters are supposed to be resolved in the order you have placed them in the Intents Definition file in Xcode (see timestamp 13:02 through 13:16). In my objective C implementation, this is not happening. I deleted the derivedData and clean the build file, but that did not help. Here is a screenshot of my intents definition parameters: In my implementation, it seems to first process the parameters that do not have "Dynamic Options" check. Then it circles back and works on the ones that have "Dynamic Options". So in my case, it starts with partName, quantity, dimensions, thickness, width, and length. Then it works on partsListName. Furthermore, while the "Disambiguation Prompt" is spoken/written, the "Disambiguation Introduction" is NOT spoken/written. Is this a bug that is causing the parameters to be resolved in the wrong order, or do I need to do something differently to force it to resolve parameters in the order that I need it to go in? And are the "Disambiguation Introduction" supposed to work?
Posted
by jeffb6688.
Last updated
.
Post not yet marked as solved
1 Replies
296 Views
How to disable iOS Shortcut ( Automation ) Programmatically ? I have made an automation to open my app whenever a user opens Facebook app. When the user taps on "Continue with Facebook" the automation which is forcing to open my App show be disabled for 2 minutes. How can I achieve this?
Posted
by Dropouts.
Last updated
.
Post not yet marked as solved
0 Replies
267 Views
@MainActor perform() async throws -> some IntentResult { // ... switch locationManager.authorizationStatus { case .denied, .restricted: throw UserLocationError.permissionDenied case .notDetermined: await locationManager.requestWhenInUseAuthorization() // to ask permission default: break } // ... } Here is my code. When the authorizationStatus is .notDetermined, it invokes requestWhenInUseAuthorization() method on the main thread, but throws UserLocationError.permissionDenied immediately, eventhough I didn't deny the permission. It's really weird and unexpected that it throws UserLocationError.permissionDenied when the status is not .denied or .restricted Even it invokes requestWhenInUseAuthorization(), there's no alert for asking permission If there's any solution, please let me know
Posted
by x_0o0.
Last updated
.
Post not yet marked as solved
0 Replies
420 Views
Hello, I'm working on my first app. It's also my first encounter with App Intents. I have a data structure for events that has an ID (String), a name (String), a Date and an image (Data). The user can create them in the app and they are stored with CoreData. I wanted to have a widget that would allow the user to choose from their list of events and display that event in the widget. The list should appear in the widget configuration and it would be a list of the names and (if possible) the image. I think I have found how to access the information from the widget, but I cannot figure out how to have the list appear in the configuration. I have been following this guide: https://developer.apple.com/documentation/widgetkit/making-a-configurable-widget?utm_source=pocket_saves. But that one shows hardcoded elements in the list and I haven't been able to find how to have the list change in relation to the content of the app. This is what I have made so far in the AppIntent file: import WidgetKit import AppIntents import CoreData struct EventDetail: AppEntity { static var defaultQuery: EventQuery = EventQuery() var id: String var date: Date var image: Data var title: String static var typeDisplayRepresentation: TypeDisplayRepresentation = "Event" var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(id) \(title)") } } struct EventQuery: EntityQuery{ func entities(for identifiers: [EventDetail.ID]) async throws -> [EventDetail] { return fill_event_details(events_list: getEventDataIntent()) } func suggestedEntities() async throws -> [EventDetail] { fill_event_details(events_list: getEventDataIntent()).filter { $0.id != "-" } } func defaultResult() async -> EventDetail? { try? await suggestedEntities().first } } struct ConfigurationAppIntent: WidgetConfigurationIntent { static var title: LocalizedStringResource = "Select an event" static var description = IntentDescription("This is an example widget.") // An example configurable parameter. @Parameter(title: "Event") var event: EventDetail // init(events: [UserCountdowns]) { // self.event = fill_event_details(events_list: events)[0] // print("AppIntent") // print(self.event.title) // } init() { } } func fill_event_details(events_list: [UserCountdowns]) -> [EventDetail] { var entities_list: [EventDetail]? let events = getEventDataIntent() for event in events { entities_list!.append(EventDetail(id: event.id!, date: event.date!, image: event.image!, title: event.title!)) } return entities_list ?? [EventDetail(id: "-", date: Date(), image: Data(), title: "empty")] } func getEventDataIntent() -> [UserCountdowns] { let context = PersistenceController.shared.container.viewContext let request = UserCountdowns.fetchRequest() var result: [UserCountdowns]! do { result = try context.fetch(request) } catch { print(error) } return result } I have been trying a few things in the widget's code but I haven't been able to make anything work, so I don't really have anything worth sharing, I think. This is the code for the UserCountdowns structure: extension UserCountdowns { @nonobjc public class func fetchRequest() -> NSFetchRequest<UserCountdowns> { return NSFetchRequest<UserCountdowns>(entityName: "UserCountdowns") } @NSManaged public var date: Date? @NSManaged public var image: Data? @NSManaged public var title: String? @NSManaged public var id: String? } Could anyone help me with this, please? What am I missing or what would the next step be? Let me know if there is any other part of the code I should share. Thank you in advance!
Posted Last updated
.
Post not yet marked as solved
2 Replies
717 Views
I have an app that relies heavily on AppIntents and Shortcuts and it seems like the latest iOS update broke those but I can't quite figure out what's the issue. The is that no matter what parameter I pick, when running the shortcut it always uses the defaultResult() Here's an example AppEntity: struct IntentBrokerAppEntity: AppEntity { static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Intent Broker") @Property(title: "Name") var name: String? @Property(title: "Ip") var ip: String? @Property(title: "Port") var port: String? @Property(title: "Username") var username: String? @Property(title: "Password") var password: String? @Property(title: "Tls") var tls: Bool? struct IntentBrokerAppEntityQuery: EntityQuery { func entities(for identifiers: [IntentBrokerAppEntity.ID]) async throws -> [IntentBrokerAppEntity] { return try await suggestedEntities().filter { identifiers.contains($0.id) } } func suggestedEntities() async throws -> [IntentBrokerAppEntity] { let context = PersistenceController.shared.viewContext let brokerService = BrokerService(context: context) return brokerService.getFavorites().map { IntentBrokerAppEntity(broker: $0) } } func defaultResult() async -> IntentBrokerAppEntity? { try? await suggestedEntities().first } } static var defaultQuery = IntentBrokerAppEntityQuery() var id: String // if your identifier is not a String, conform the entity to EntityIdentifierConvertible. var displayString: String var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(displayString)") } ... This used to work perfectly fine before 17.2, but now instead of choosing the entity the user picked it always falls back to defaultEntity(). In the console I get this warning Failed to build EntityIdentifier. IntentBrokerAppEntity is not a registered AppEntity identifier But I'm not sure if that's related. Does anyone have any ideas on what's going on here? Input much appreciated!
Posted Last updated
.
Post not yet marked as solved
0 Replies
555 Views
I'm writing an application with App Shortcuts support. My task is to write a command that will check whether a certain application is open and runs the command. For example: The user installed a command through my application that responds to the Instagram application The user goes to Instagram My team is starting Question: Is it possible to organize this?
Posted Last updated
.
Post not yet marked as solved
0 Replies
365 Views
I've created a barebones Multiplatform app and added an App Intent and App Shortcut. When running on iOS, I can see my app show up in Shortcuts and use the intent or App Shortcut as normal. On macOS, my app does not appear in the Shortcuts app, neither the App Shortcut nor the intent. Is there additional configuration required to enable Shortcuts / App Intents on macOS? This is the only code I've added to a brand-new Xcode Multiplatform project: import AppIntents struct OpenIntent: AppIntent { static let title: LocalizedStringResource = "Open MacShortcut" static let description: LocalizedStringResource = "Opens the app" /// Launch your app when the system triggers this intent. static let openAppWhenRun: Bool = true /// Define the method that the system calls when it triggers this event. @MainActor func perform() async throws -> some IntentResult { /// Return an empty result since we're opening the app return .result() } } struct MacShortcutShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: OpenIntent(), phrases: [ "Open a session of \(.applicationName)" ], shortTitle: "Open", systemImageName: "arrow.up.circle.fill" ) } }
Posted
by Ethan_.
Last updated
.