I've been taking a look at the documentation for donating a shortcut to siri, as well as a few blogposts about it. I've managed to add a shortcut to my app using NSUserActivity
:
let activity = NSUserActivity(activityType: "com.myapp.mobile")
activity.title = "Some title"
activity.isEligibleForSearch = true
activity.isEligibleForPrediction = true
activity.suggestedInvocationPhrase = "Summon my app please"
activity.persistentIdentifier = NSUserActivityPersistentIdentifier(rawValue: "com.myapp.mobile")
view.userActivity = activity
activity.becomeCurrent()
But so far I have no clue on how I should go about internationalization on the shortcuts. Should I translate suggestedInvocationPhrase
and title
before passing them down to the activity or does Siri handles that?
You need to treat the text you pass to the NSUserActivity just like any other text in your app - localize the text before you pass it to the activity.