2

I am unable to set separate Siri shortcut phrases through INUIAddVoiceShortcutButton if there are two buttons in a single view. As soon as I record phrase for one button the other button gets changed to edit mode along with first button. How can I resolve that issue?

Screen before recording phrase Screen after recording phrase

func firstShortcut() {

    let activity1 = NSUserActivity(activityType: "com.test.first")
    activity1.title = "Log first activity"
    activity1.isEligibleForSearch = true
    activity1.suggestedInvocationPhrase = "Log my first activity"
    activity1.isEligibleForPrediction = true
    activity1.persistentIdentifier = "com.test.first"
    view.userActivity = activity1
    activity1.becomeCurrent()

    let addShortcutButton = INUIAddVoiceShortcutButton(style: .whiteOutline)
    addShortcutButton.shortcut = INShortcut(userActivity: activity1)
    addShortcutButton.delegate = self
    addShortcutButton.translatesAutoresizingMaskIntoConstraints = false
    addSiriShortcutView1.addSubview(addShortcutButton)
    addSiriShortcutView1.centerXAnchor.constraint(equalTo: addShortcutButton.centerXAnchor).isActive = true
    addSiriShortcutView1.centerYAnchor.constraint(equalTo: addShortcutButton.centerYAnchor).isActive = true
}

func secondShortcut() {

    let activity2 = NSUserActivity(activityType: "com.test.second")
    activity2.title = "Log second activity"
    activity2.isEligibleForSearch = true
    activity2.suggestedInvocationPhrase = "Log my second activity"
    activity2.isEligibleForPrediction = true
    activity2.persistentIdentifier = "com.test.second"
    view.userActivity = activity2
    activity2.becomeCurrent()

    let addShortcutButton = INUIAddVoiceShortcutButton(style: .whiteOutline)
    addShortcutButton.shortcut = INShortcut(userActivity: activity2)
    addShortcutButton.delegate = self
    addShortcutButton.translatesAutoresizingMaskIntoConstraints = false
    addSiriShortcutView2.addSubview(addShortcutButton)
    addSiriShortcutView2.centerXAnchor.constraint(equalTo: addShortcutButton.centerXAnchor).isActive = true
    addSiriShortcutView2.centerYAnchor.constraint(equalTo: addShortcutButton.centerYAnchor).isActive = true
}
Tarun Jain
  • 21
  • 3
  • 1
    Found similar problem here: https://stackoverflow.com/questions/52342934/siri-shortcut-button-inuiaddvoiceshortcutbutton-shows-wrong-title-when-have-mu/52440181 – Tarun Jain Oct 09 '18 at 05:33

0 Answers0