Siri Intent Donation for Shortcuts ending up with error
Asked Answered
K

3

9

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")
                }
            }
        }
    }
Kippie answered 17/7, 2018 at 12:44 Comment(1)
Can you show me your .intentdefinition file? A print will be enoughBlintz
K
12

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")
                }
            }
        }
    }
Kippie answered 4/8, 2018 at 17:8 Comment(1)
You really have to add all properties, even enums that are not optional (and I thought would have a default value)Larentia
B
3

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.

Bellbottoms answered 24/8, 2018 at 1:20 Comment(1)
Hey, were you able to successfully run multiple intents?Ringnecked
A
1

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

Apanage answered 2/8, 2018 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.