Implement App Shortcuts with App Intents

RSS for tag

Discuss the WWDC22 Session Implement App Shortcuts with App Intents

Posts under wwdc2022-10170 tag

3 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

App Intents with OpensIntent does not work correctly
We are developing an app for iOS 16 using App Intents and Siri. We have been testing the behavior of opening another App Intent by passing the opensIntent argument to the result function in the App Intent with iOS 16.4 devices. As a result, we found that the dialog text specified in the result argument of the Intent to which it transitions is not displayed and therefore does not work. And also found that when invoked from Siri, the Intent passed to the opensIntent argument is invoked "twice". Are these behaviors bugs? Any ideas? The following is a sample code and logs. import AppIntents struct PrimaryIntent: AppIntent { static var title: LocalizedStringResource = "Primary" func perform() async throws -> some OpensIntent { print("\(String(describing: Self.self)).\(#function): invoked") return .result(opensIntent: SecondaryIntent()) } } struct SecondaryIntent: AppIntent { static var title: LocalizedStringResource = "Secondary" func perform() async throws -> some ProvidesDialog { print("\(String(describing: Self.self)).\(#function): invoked") return .result(dialog: .init(stringLiteral: "test")) } } struct ShortcutsProvider: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut(intent: PrimaryIntent(), phrases: ["\(.applicationName)"]) } } logs from Shortcut App PrimaryIntent.perform(): invoked SecondaryIntent.perform(): invoked # is not displayed dialog... logs from Siri PrimaryIntent.perform(): invoked SecondaryIntent.perform(): invoked SecondaryIntent.perform(): invoked # is not displayed dialog... # SecondaryIntent invoked twice...
1
1
1.4k
Aug ’23
App Shortcut "Couldn't find AppShortcutsProvider"
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"   )  } }
5
1
2.3k
Sep ’23