Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Siri Intent Donation for Shortcuts ending up with error

I have created a simple intent for Siri shortcut and whenever i am trying to donate the intent, it is ending up with following error.

Interaction donation failed: %@ Error Domain=IntentsErrorDomain Code=1901 "Cannot donate interaction { intent = { user = ; identifier = 06DE1A38-6D46-4CB8-B825-3788E6A81420; }; dateInterval = <_NSConcreteDateInterval: 0x60000043cce0> (Start Date) 2018-07-17 12:38:39 +0000 + (Duration) 0.000000 seconds = (End Date) 2018-07-17 12:38:39 +0000; intentResponse = ; groupIdentifier = ; intentHandlingStatus = Unspecified; identifier = F145FA84-7147-41A8-8698-681F06C8CEB5; direction = Unspecified; } with intent that has no valid shortcut types" UserInfo={NSLocalizedDescription=Cannot donate interaction { intent = { user = ; identifier = 06DE1A38-6D46-4CB8-B825-3788E6A81420; }; dateInterval = <_NSConcreteDateInterval: 0x60000043cce0> (Start Date) 2018-07-17 12:38:39 +0000 + (Duration) 0.000000 seconds = (End Date) 2018-07-17 12:38:39 +0000; intentResponse = ; groupIdentifier = ; intentHandlingStatus = Unspecified; identifier = F145FA84-7147-41A8-8698-681F06C8CEB5; direction = Unspecified; } with intent that has no valid shortcut types}

The following is my intent donation code

func donateInteraction() {
        let intent = GetBalanceIntent()
        intent.suggestedInvocationPhrase = "Get Balance"
        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")
                }
            }
        }
    }
like image 238
Vittal Pai Avatar asked Jul 17 '18 12:07

Vittal Pai


3 Answers

I missed initializing the custom property(i.e user in the above example) which i have defined in the definition file.

Adding it solved the problem. Code looks like this:

func donateInteraction() {
        let intent = GetBalanceIntent()
        intent.suggestedInvocationPhrase = "Get Balance"
        intent.user = "vittal"
        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")
                }
            }
        }
    }
like image 93
Vittal Pai Avatar answered Nov 17 '22 09:11

Vittal Pai


enter image description here

I had the same problem, I realized that my INIntent subclass name on my swift file wasn't matching the one in the . intentdefinition, hope this helps someone.

like image 28
James Rochabrun Avatar answered Nov 17 '22 11:11

James Rochabrun


Your intent definition file should have valid shortcut types. You can add those under shortcut types.

like image 1
Vinay Podili Avatar answered Nov 17 '22 09:11

Vinay Podili