Sunday, January 28, 2024
HomeiOS Developmentios - AppIntent error when operating in app killed state with out...

ios – AppIntent error when operating in app killed state with out openAppWhenRun


On iOS, when making an attempt to run an AppIntent that is added to the Shortcuts app and my app is in a killed state, I get the next error: Error Area=LNActionForAutoShortcutPhraseFetchError Code=1 "Could not discover AppshortcutsProvider." UserInfo={NSLocalizedDescription=Could not discover AppShortcutsProvider. It appears from the error that the AppShortcutsProvider can’t be discovered, nevertheless once I run the shortcut when the app will not be in a killed state, it runs completely fantastic.

Related code beneath:

struct ExampleIntent: AppIntent, WidgetConfigurationIntent {
        
    static let title: LocalizedStringResource = "Title"
    static let description: IntentDescription = IntentDescription("Description")
    
    func carry out() async throws -> some IntentResult & ProvidesDialog {
        // Performing related logic
        return .end result(
            dialog: IntentDialog(stringLiteral: "End result message")
        )
    }
}

AppShortcutsProvider (in the principle app, not in an extension):

@out there(iOS 17.0, *)
struct ExampleShortcutsProvider: AppShortcutsProvider {
        
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: ExampleIntent(),
            phrases: ["Perform the example intent"],
            shortTitle: "Instance Shortcut",
            systemImageName: "data.circle.fill"
        )
    }
}

If I add static let openAppWhenRun: Bool = true to the ExampleIntent, it runs completely fantastic, additionally when the app is in a killed state. I couldn’t discover any documentation on this – does anybody know why that is the conduct?



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments