Hi there, I am trying to add a simple intent (just a URL parameter) to my application, and it shows up in the shortcuts app. However, when I try to donate the intent from the app, there is a weird error that shows up and I have been struggling with it for a long time.
What even is a shortcut type, isn't a system type considered valid or no?
2022-07-18 17:29:08.342668-0400 Asobi[25910:394998] [Intents] -[INInteraction donateInteractionWithCompletion:]_block_invoke Cannot donate interaction with LoadUrlIntent that has no valid shortcut types
Interaction donation failed: %@ Error Domain=IntentsErrorDomain Code=1901 "Cannot donate interaction with intent that has no valid shortcut types: <INInteraction: 0x600000fe1680> {
intent = <INIntent: 0x6000019ec870> {
};
dateInterval = <_NSConcreteDateInterval: 0x600002b4f260> (Start Date) 2022-07-18 21:29:08 +0000 + (Duration) 0.000000 seconds = (End Date) 2022-07-18 21:29:08 +0000;
intentResponse = <null>;
groupIdentifier = <null>;
intentHandlingStatus = Unspecified;
identifier = B3A8CA1F-6CCD-4AC3-8A9F-1D8A1B23834F;
direction = Unspecified;
} for intent <LoadUrlIntent: 0x6000019e81b0> {
url = https://google.com;
}" UserInfo={NSLocalizedDescription=Cannot donate interaction with intent that has no valid shortcut types: <INInteraction: 0x600000fe1680> {
intent = <INIntent: 0x6000019ec870> {
};
dateInterval = <_NSConcreteDateInterval: 0x600002b4f260> (Start Date) 2022-07-18 21:29:08 +0000 + (Duration) 0.000000 seconds = (End Date) 2022-07-18 21:29:08 +0000;
intentResponse = <null>;
groupIdentifier = <null>;
intentHandlingStatus = Unspecified;
identifier = B3A8CA1F-6CCD-4AC3-8A9F-1D8A1B23834F;
direction = Unspecified;
} for intent <LoadUrlIntent: 0x6000019e81b0> {
url = https://google.com;
}}
The intent definitions file is provided in this link (since I cannot attach it) https://gist.github.com/bdashore3/c370bf3459ea78180273c9bf00e0c74f
Here is the button code for calling the donation function (which provides the error shown)
Button("Donate intent") {
let intent = LoadUrlIntent()
intent.suggestedInvocationPhrase = "Open google"
intent.url = URL(string: "https://google.com")
let interaction = INInteraction(intent: intent, response: nil)
interaction.donate { (error) in
if error != nil {
if let error = error as NSError? {
print("Interaction donation failed: %@", error)
} else {
print("Successfully donated interaction")
}
}
}
}