Let's say I've defined a custom intent, called FooIntent, in an .intentdefinition file.
It has a single parameter, bar, of type Decimal, for which:
- User can supply value in Siri and Shortcuts app is active.
- Default Value is 0.
Its autogenerated class definition now looks like this:
public class FooIntent: INIntent {
@NSManaged public var bar: NSNumber?
}
If I construct a FooIntent, set bar to nil, and pass it into a INUIAddVoiceShortcutViewController:
let intent = FooIntent()
intent.bar = nil
intent.suggestedInvocationPhrase = "Do foo"
let shortcut = INShortcut(intent: intent)
let viewController = INUIAddVoiceShortcutViewController(shortcut: shortcut!)
viewController.delegate = self
window?.rootViewController?.present(viewController, animated: true, completion: nil)
the Add to Siri modal appears with the bar parameter filled in with 0, its default value.
If, in the Add to Siri UI, I then change bar to Ask Each Time and press Add to Siri, the resulting delegate method call produces an INVoiceShortcut object that contains a nil value for bar:
func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController, didFinishWith shortcut: INVoiceShortcut?, error: Error?) {
if let intent = shortcut?.shortcut.intent as? FooIntent {
print(intent.bar) // nil
}
controller.dismiss(animated: true, completion: nil)
}
The same is true if I set bar to Clipboard in the UI.
If I set it to a value, e.g. 42, then intent.bar correctly returns 42.
Since nil seems to represent multiple concepts for a parameter, where is the concept of Ask Each Time stored in the shortcut or intent objects?
Is there anything I can pass into INUIAddVoiceShortcutViewController such that intent.bar = <Ask Each Time>?