0

I’m working on supporting iOS 17’s new Shortcuts features. I have a multiple App Shortcuts including one that launches the app in a selected tab. The tab selection is done via a custom AppView enum that conforms to the AppEnum protocol.

The problem is that for some reason the open in view XYZ action doesn’t show correctly in Spotlight. As you can see in the screenshot below it doesn’t have any icon or title. Also in the Shortcuts app itself only the Action resulting from the first phrase shows up. The AppView based phrase actions only show up as old App Shortcuts below.

Any idea how to fix that issue?

App Shortcuts Definition

struct AppShortcuts: AppShortcutsProvider {
    static var shortcutTileColor: ShortcutTileColor = .grape
    
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: OpenAppIntent(),
            phrases: [
                "Open \(.applicationName)",
                "Open \(\.$view) in \(.applicationName)"
            ],
            shortTitle: "Open",
            systemImageName: "arrow.up.forward.app"
        )
        // Other App Shortcuts …
    }
}

AppView App Enum

extension AppView: AppEnum {
    static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "View")
    
    static var caseDisplayRepresentations: [Self : DisplayRepresentation] = [
        .insights: DisplayRepresentation(title: LocalizedStringResource("Insights", table: "Shortcuts", comment: "App View Label"),
                                         image: .init(systemName: "chart.xyaxis.line")),
        .events: DisplayRepresentation(title: LocalizedStringResource("Events", table: "Shortcuts", comment: "App View Label"),
                                       image: .init(systemName: "calendar")),
        .meters: DisplayRepresentation(title: LocalizedStringResource("Meters", table: "Shortcuts", comment: "App View Label"),
                                       image: .init(systemName: "barometer"))
    ]
}

Shortcut Definition

struct OpenAppIntent: AppIntent {
    
    // Launches app when action is triggered
    static let openAppWhenRun: Bool = true
    
    // App View Parameter
    @Parameter(title: "View",
               description: "The view inside the app.",
               default: .insights,
               requestValueDialog: IntentDialog("Where would you like to navigate to?"))
    var view: AppView
    
    // Title, Description, Parameter Summary & perform()
}

Screenshots

App Shortcuts in Spotlight App Shortcuts in the Shortcuts App

alexkaessner
  • 1,966
  • 1
  • 14
  • 39

0 Answers0