I'm implementing Siri Shortcut. My objective is add shortcuts of functions to SIRI SHORTCUT on Settings app.
In order to do so, I need to first register NSUserActivity & then handle the shortcuts calls from app delegate.
The problem is I'm not sure where and how to register the activity properly from a tutorail I watched.
Where should I register?
According to the tutorial I added this code on a view controller.
Since self.userActivity is accessible from app delegete I'm wondering if I could add the code below on app delegate.
func registerShortcut() {
if #available(iOS 12.0, *) {
let activity = NSUserActivity(activityType: "jp.co.mycompany.MyApp.openCamera")
activity.title = "Camera Shortcut"
activity.isEligibleForSearch = true
activity.isEligibleForPrediction = true
self.userActivity = activity
self.userActivity?.becomeCurrent()
}
}
How many times should I register
Without controlling how many times the registration code is called, app will call the registration code everytime app is launched. Is calling the registration multiple times causes any problem?