Marco
Marco

Reputation: 634

IntentHandler called with empty parameter

I'm new to iOS development, and I'm trying to add support for Siri Shortcuts to my app with the purpose of allowing Siri to suggest a common user actions in the various "Siri Suggestions" widgets throughout iOS 14.

Using Apple's documentation and various other sources I managed to reach the point where I'm creating the intents, passing a parameter and donating the intent to the OS (in the form of INInteraction). So far, they haven't shown up in the widgets, but I can see the suggestions in the Siri search.

However, when tapping the shortcut, my IntentHandler is called with an intent that's basically empty. When I print the intent upon reception, it is of the right class, but it's parameter is empty.

My intent definition enter image description here

The StatusUpdate Type used as the intent's parameter enter image description here

Intent donation code

func donateInteraction(for status: StoredStatus) {
    //  Create the intent we're going to donate
    let intent = SetStatusIntent()
    // Create the status `type` associated with the intent, and add it to the intent
    let statusUpdate = StatusUpdate(identifier: status.uuid, display: status.status.asString)
    intent.status = statusUpdate
    
    let interaction = INInteraction(intent: intent, response: nil)
    // The identifier is used to match with the donation so the interaction
    // can be deleted if the status is removed.
    interaction.identifier = status.uuid
    
    interaction.donate { (error) in
        if error != nil {
            print(error as Any)
        }
    }
}

Basically, I want the shortcut to arrive at the IntentHandler with some form of identifier for the action that the user performed. I figured this is what the parameters are for, but it doesn't seem to actually pass this parameter, even though the suggestion in the search results is specific to the interaction I've created.

I would love to know what I'm doing wrong here, and — additionally — if there's a reason the suggestions only show up in the search screen, and not any of the suggestions widgets.

Upvotes: 1

Views: 1318

Answers (1)

Marco
Marco

Reputation: 634

Thanks to some help of a friend I found that unchecking the "Intent is user configurable in the Shortcuts app…" option seemed to fix this for me.

Not sure why, this might be a bug on Apple's side. But it works!

Upvotes: 1

Related Questions