INUIAddVoiceShortcutButton doesn't work if Shortcuts App is deleted

396 views Asked by At

I had added a INUIAddVoiceShortcutButton which works fine, but when I delete the Shortcuts App it stops working. The delegates still return that the shortcut was successful, but the button doesn't change to reflect that the shortcut was added. I found that I have to re-install the Shortcuts app AND restart my phone to return function.

Is there a way to determine if the Ahortcuts app is install? Is there something missing?

I also tested this with Apple's demo Soup Chef app.

1

There are 1 answers

0
Michael Ozeryansky On

The best I've found is calling INVoiceShortcutCenter.shared.getAllVoiceShortcuts returns an error:

Optional(
    Error Domain=IntentsErrorDomain
    Code=7001 "Failed to get voice shortcuts"
    UserInfo={
        NSDebugDescription=Failed to get voice shortcuts,
        NSUnderlyingError=0x283c42910
        {
            Error Domain=VCVoiceShortcutsErrorDomain
            Code=1004
            "Shortcuts app is not installed"
            UserInfo={NSLocalizedFailureReason=Shortcuts app is not installed
        }
    }}
)

And after adding the shortcut it returns nil:

func addVoiceShortcutViewController(_ controller: INUIAddVoiceShortcutViewController, didFinishWith voiceShortcut: INVoiceShortcut?, error: Error?) {
    INVoiceShortcutCenter.shared.getVoiceShortcut(with: voiceShortcut!.identifier) { (shortcut, error) in
        print("\(String(describing: shortcut))") // nil
        print("\(error.debugDescription)") // nil
    }
}