1

I have a very simple AppIntent and AppShortcutsProvider. It's working great in the Shortcuts app, but it just will not work when asking Siri.

// MARK: - OpenLibrary
struct OpenLibrary: AppIntent {
    static let title: LocalizedStringResource = "Open Library"
    static let description = IntentDescription("Opens your saved songs and playlists.")
    static var openAppWhenRun: Bool = true
    
    @MainActor
    func perform() async throws -> some IntentResult & ReturnsValue {
        
        if let url = URL(string: "appName://library/open") {
            await UIApplication.shared.open(url)
        }
        return .result()
    }

}

struct OpenLibraryShortcutsProvider: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: OpenLibrary(),
            phrases: [
                "Open Library in \(.applicationName)",
                "Open \(.applicationName) Library",
                "Open my library in \(.applicationName)",
                "Open my \(.applicationName) Library"
            ],
            shortTitle: "Open Library",
            systemImageName: "rectangle.stack.fill"
        )
    }
    
    static var shortcutTileColor: ShortcutTileColor = .lightBlue
}

I'm saying to Siri, on my iPhone, "Open my library in {appName}" and Siri responds with "{appName} hasn't added support for that with Siri". As I mentioned before, if I create and run this as a Shortcut, it works fine. The URL is handled correctly.

I'm just now learning AppIntent. What can I try next?

halfer
  • 19,824
  • 17
  • 99
  • 186
Jacob Cavin
  • 2,169
  • 3
  • 19
  • 47

1 Answers1

0

First add Siri in Signing & Capabilities.

As far as I can tell you need to invoke an AppShortcut phrase from siri with the app open. This will then trigger a dialog asking "Turn on "<.applicationName>" with Siri? If the user selects "Turn On" then the shortcuts will start working from anywhere on iPhone.

enter image description here

Javier Refuerzo
  • 274
  • 3
  • 7